curl-library
Re: Problem using RECORDFUNCTION
Date: Mon, 2 Jun 2014 17:45:47 -0400
Hi,
Ok. Thanks. I want to send each chunk as binary not ascii in the post. Is there an option I need to set using CURLOPT to do this?
Thanks.
-Jon
On Jun 2, 2014, at 5:27 PM, Dan Fandrich <dan_at_coneharvesters.com> wrote:
> On Mon, Jun 02, 2014 at 05:17:47PM -0400, Jon Lederman wrote:
>> Hi,
>>
>> I am using chunked encoding. I looked at the debug output. It should be transferring 1 byte with each chunk. Yet the chunk size seems to indicate 31 hex=49. Why should this be? See below:
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 74 0d 0a 1..t..
>
> 0x31 is ASCII '1' which means one byte, which seems to be correct and matches
> what you are expecting.
>
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 68 0d 0a 1..h..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 69 0d 0a 1..i..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 73 0d 0a 1..s..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 20 0d 0a 1.. ..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 69 0d 0a 1..i..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 73 0d 0a 1..s..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 20 0d 0a 1.. ..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 77 0d 0a 1..w..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 68 0d 0a 1..h..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 61 0d 0a 1..a..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 74 0d 0a 1..t..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 20 0d 0a 1.. ..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 77 0d 0a 1..w..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 65 0d 0a 1..e..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 20 0d 0a 1.. ..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 70 0d 0a 1..p..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 6f 0d 0a 1..o..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 73 0d 0a 1..s..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 74 0d 0a 1..t..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 20 0d 0a 1.. ..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 74 0d 0a 1..t..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 6f 0d 0a 1..o..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 20 0d 0a 1.. ..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 74 0d 0a 1..t..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 68 0d 0a 1..h..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 65 0d 0a 1..e..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 20 0d 0a 1.. ..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 73 0d 0a 1..s..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 69 0d 0a 1..i..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 6c 0d 0a 1..l..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 6c 0d 0a 1..l..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 79 0d 0a 1..y..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 20 0d 0a 1.. ..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 77 0d 0a 1..w..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 65 0d 0a 1..e..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 62 0d 0a 1..b..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 20 0d 0a 1.. ..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 73 0d 0a 1..s..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 65 0d 0a 1..e..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 72 0d 0a 1..r..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 76 0d 0a 1..v..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 65 0d 0a 1..e..
>> => Send data, 0000000006 bytes (0x00000006)
>> 0000: 31 0d 0a 72 0d 0a 1..r..
>> => Send data, 0000000005 bytes (0x00000005)
>> 0000: 30 0d 0a 0d 0a 0....
>> On Jun 2, 2014, at 3:07 PM, Dan Fandrich <dan_at_coneharvesters.com> wrote:
>>
>>> On Mon, Jun 02, 2014 at 08:50:54AM -0400, Jon Lederman wrote:
>>>> I am trying to mimic the following command line curl request in libcurl programatically in C/C++. Instead of reading data from a file though, I want to send binary data from a buffer in memory:
>>>> curl "https://website.net:443/Command?appId=XXX&appKey=YYY5&id=ZZZ" -H "Content-Type: AAA;codec=BBB" -H "Accept-Language: ENUS" -H "Transfer-Encoding: chunked" -H "Accept: application/xml" -H "Accept-Topic: New" -k --data-binary @data.bin -v
>>>>
>>>> I am using post-callback.c as a model. I am have set up the headers correctly. What I donąt fully understand is how to use READFUNCTION. When I use the technique in post-callback, I get the following error below. Could you point me to an example of how to use READFUNCTION with binary data from a buffer? I would like to see more examples.
>>>
>>> There are 12 example programs using CURLOPT_READFUNCTION in docs/examples/.
>>> Also, the --libcurl curl option will write a little example program for you,
>>> although not the callback functions.
>>>
>>>> Thanks in advance.
>>>>
>>>> <
>>>> <html>
>>>> <head>
>>>> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
>>>> <title>Error 500 x-a-sessionidf38693fc-e97b-4d43-abea-907790367183
>>>> Received QueryRetry: 2 AUDIO_INFO</title>
>>>> </head>
>>>> <body><h2>HTTP ERROR 500</h2>
>>>> <p>Problem accessing /XXX. Reason:
>>>> <pre> x-XXX-sessionidf38693fc-e97b-4d43-abea-907790367183
>>>> Received QueryRetry: 2 AUDIO_INFO</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>
>>>
>>> This likely means that the server didn't like what it was sent and returned an
>>> error. Try comparing the output of libcurl (using a debug callback or network
>>> trace tool) with a successful transfer by a browser or other and see where the
>>> differences lie.
>>>
>>>>>> Dan
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-06-02