curl-library
header mysteries when not using curl_slist_append
Date: Fri, 01 Mar 2013 18:02:17 -0500
I need to post some xml data to a remote point and then wait and listen for a reply.
This all seems to be going well except for the mystery of headers. I really don't know
what headers are really being sent to the remote url and wonder if libcurl adds in
things I don't know about.
I am doing this sort of thing :
const char *verb = "POST / HTTP/1.1\r\nHost: some.correcturl.com\r\nContent-type: text/xml; charset=\"utf-8\"\r\n";
char *query_buffer;
char *input_buffer;
size_t tu_query_length;
I check the size of my input xml file and calloc the buffer and read in the data :
xml_stat = stat ( "./test.xml", &xmlfid );
if ( xml_stat != 0 ) {
perror ( "INPUT xml file Error: " );
exit ( EXIT_FAILURE );
}
input_buffer = calloc( (size_t) xmlfid.st_size + 1,
(size_t) sizeof( unsigned char ) );
then create my output to go to the remote point :
strcpy ( query_buffer, verb );
strcat ( query_buffer, input_buffer );
setup a few options and do the work :
curl_global_init( CURL_GLOBAL_DEFAULT );
curl = curl_easy_init();
if ( curl ) {
curl_easy_setopt ( curl, CURLOPT_URL,
"https://some.remoteurl.com/foo/bar.cgi" );
curl_easy_setopt ( curl, CURLOPT_WRITEHEADER, headerfile );
curl_easy_setopt ( curl, CURLOPT_STDERR, logfile );
curl_easy_setopt ( curl, CURLOPT_VERBOSE, 1L );
curl_easy_setopt ( curl, CURLOPT_HEADER, 1L );
curl_easy_setopt ( curl, CURLOPT_NOPROGRESS, 0L );
curl_easy_setopt ( curl, CURLOPT_SSL_VERIFYPEER, 0L );
curl_easy_setopt ( curl, CURLOPT_POST, 1L );
/* Do not do the transfer - only connect to host */
curl_easy_setopt ( curl, CURLOPT_CONNECT_ONLY, 1L);
res = curl_easy_perform ( curl );
then I follow the sendrecv.c example to wait on the socket and get a reply .. which all seems to work.
However I always get a "HTTP/1.1 400 Bad Request" .
So I am curious what other headers is libcurl adding if any ?
Dennis
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-03-02