curl-library
Re: CURLOPT_HTTPHEADER ignored?
Date: Wed, 8 Oct 2014 13:38:25 -0300
Lucas Manuel RodrÃguez.
On 8 October 2014 12:17, Chris Johnson <cxjohnson_at_gmail.com> wrote:
> libcurl 7.37.1 (FreeBSD 10 port)
>
> I'm setting an explicit Content-Type header for my POST operation to a SOAP
> service. The value I'm setting, via curl_easy_setopt(curl,
> CURLOPT_HTTPHEADER, headers)
> ,
> is "application/soap+xml". However, when executed, libcurl is actually
> sending "application/x-www-form-urlencoded".
>
> Is there some condition under which this is
> e
> xpected behavior? It seems like it's just wrong.
>
> Most of the relevant code looks like this:
>
> struct curl_slist* headers;
> headers = curl_slist_append(NULL, "Content-Type: application/soap+xml");
>
> bool result =
> curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC) ||
> curl_easy_setopt(curl, CURLOPT_POST, 1) ||
> curl_easy_setopt(curl, CURLOPT_POSTFIELDS, 0) ||
> curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, len) ||
> curl_easy_setopt(curl, CURLOPT_READDATA, (void*)this) ||
> curl_easy_setopt(curl, CURLOPT_READFUNCTION, source) ||
> curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers) ||
> sendRequest();
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
Hello Chris,
Just two comments:
1) Maybe one of the previous setopts is failing and you don't get to
set CURLOPT_HTTPHEADER.
Try splitting them and analyze the return code:
...
int rc = curl_easy_setopt(curl, CURLOPT_POST, 1);
// Check rc value
...
2) Adding
// This is just as -v on the curl command
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
may help you troubleshoot the issue.
Hope that helps.
Regards,
Lucas Manuel RodrÃguez.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-10-08