cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Problem using RECORDFUNCTION

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Mon, 2 Jun 2014 21:07:32 +0200

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
Received on 2014-06-02