curl-library
RE: Post using https -- how can I avoid "Content-Length: 0"?
Date: Wed, 14 Mar 2012 13:51:32 -0700
Daniel Stenberg wrote:
>... or do you want to pass on the data using some other means? Perhaps
>just sending the raw file in the body of the post request?
That got me thinking... maybe I could just read my file into an
internal buffer (the files I'm using are not large) and then
use curl_easy_setopt(curl, CURLOPT_POSTFIELDS,...), with a pointer to
my buffer, instead of messing with the CURLOPT_READDATA stuff.
That appears to have born fruit, since I'm now seeing in the log file:
> POST /xxxxxx.aspx HTTP/1.1
Host: xxxx.xxx.com.xx
Accept: */*
Content-Length: 3566
... which is the correct size of my buffer content.
However, I'm also seeing, immediately following that in the log,
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue
... which the host site does not like -- it wants text/xml.
I don't understand why I'm still getting these, since I've got the
following, right after the CURLOPT_POSTFIELDS call:
{
char *ps = calloc(strlen(szContentType)+14+1,1); /*
szContentType is "text/xml" */
struct curl_slist *headers=NULL;
headers = curl_slist_append(headers, "Expect:");
sprintf(ps, "Content-Type: %s", szContentType);
headers = curl_slist_append(headers, ps);
cresult = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_slist_free_all(headers); /* free custom header list */
free(ps);
if(cresult) (... exit with error message ...)
}
Shouldn't the above have both suppressed the "Expect: 100-continue",
and forced "Content-Type: text/xml" ??
Before the change to start using CURLOPT_POSTFIELDS instead of
CURLOPT_READDATA, the Content-Type forcing had been working!
Still confused, but at a slightly higher level...
-- Best Regards, Jeff Pratt ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2012-03-14