curl-and-php
Re: Data in headers [SOLVED]
Date: Wed, 10 Oct 2007 13:31:05 -0400
Daniel Stenberg wrote:
> On Wed, 10 Oct 2007, David Durant wrote:
>
>
>> Is there a way to send raw data (text/xml) inside the headers of a POST
>> command?
>>
>
> Data in the headers? Sure, providing any header with any content is possible
> with curl.
>
>
>> I'm trying to emulate the output javascript output of
>> ActiveXObject("Microsoft.XMLHTTP"), which injects the request data into the
>> headers. Everything I've tried with curl and/or http_post_data sends the
>> headers with "Expect: 100-continue", waits for the Continue response from
>> the server (which it gets), then sends the data. Unfortunately this is not
>> working correctly.
>>
>
> You mean the server isn't behaving correctly?
>
>
>> POST / HTTP/1.1
>> Accept: */*
>> Accept-Language: en-us
>> Referer: file://C:\Users\Dave\Documents\RealQuest Info\c2dtest.htm
>> UA-CPU: x86
>> Accept-Encoding: gzip, deflate
>> User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1;
>> .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; .NET CLR
>> 1.1.4322)
>> Host: staging.connect2data.com
>> Content-Length: 1062
>> Connection: Keep-Alive
>> Cache-Control: no-cache
>>
>> <?xml version = "1.0" encoding = "UTF-8"?>
>>
>
> This is a plain and simple POST and yes PHP/CURL can do them.
>
>
>> Notice the headers end with "Cache-Control: no-cache" followed by \r\n, then
>> the xml data. Can this be done with curl?
>>
>
> Yes. But there's no particular "data in headers" here, there's just
> request-headers and a request-body with the XML in the body part...
>
> Here's an example for you:
>
> http://curl.haxx.se/libcurl/php/examples/blogpost.html
>
Figured it out: if I add the line
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Expect: "));
that removes the "second packet" and packages the data into the first
packet.
Dave
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-10-10