cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: post binary data using curlopt_postfields option

From: Vemana Yogi <yogi.elgoog_at_gmail.com>
Date: Tue, 8 Jun 2010 23:25:42 -0700

Btw, the below option worked but it started to fail after the content length
was 1002. Is there any limit to how much data you can post using postfields
option or some tweak is needed here?

As an alternative, I tried using this
http://curl.haxx.se/mail/lib-2006-07/0218.html, but doing this, the
content-type I am setting is not sent correctly to the services and
something internally is being sent.. The way I am using it is.

 curl_formadd(&post, &last, CURLFORM_COPYNAME, "request", CURLFORM_BUFFER,
"test", CURLFORM_BUFFERPTR, buff, CURLFORM_BUFFERLENGT
H, bs->size(), CURLFORM_CONTENTTYPE, "application/test", CURLFORM_END);

  curl_easy_setopt(eh->getCurlMailHandle(), CURLOPT_HTTPPOST, post);

but I'm seeing application/json being sent across the wire..

 HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 400 Bad Request
< Date: Wed, 09 Jun 2010 05:31:07 GMT
< cache-control: public,must-revalidate
< content-length: 138
< content-type: application/json

any idea?

Yogi.

On Tue, Jun 8, 2010 at 11:03 PM, Vemana Yogi <yogi.elgoog_at_gmail.com> wrote:

> Hi,
>
> Can we post binary data with the below curl options:
>
> curl_easy_setopt(handle, CURLOPT_POSTFIELDS, buff);
> curl_easy_setopt(handle, CURLOPT_POSTFIELDSIZE, bs->size());
>
> ?
>
> An inline question if the answer to the above query is yes - I came across
> a page which I am not able to find now. It said, we have to pass a binary
> pointer in place of what I put in as buff - if I understand this right, this
> is just const char * right?
>
> What I am currently doing is encoding a string into binary, and would like
> to post this encoding binary data to the services. So in my case the buff
> is a custom buffer stream pointer.
>
> thanks
> Yogi

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-06-09