cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Expect: 100-continue with another Expect header does not always wait for a response

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Mon, 14 Feb 2011 15:46:16 -0800

On Mon, Feb 14, 2011 at 05:31:10PM -0600, Brian Guetzlaff wrote:
> To illustrate, here are the commands I issued:
> curl -X POST --post301 -H "Expect: 100-continue" -H "Expect:
> Content-MD5" -d @small.htm -v "http://<<server IP>>"
> curl -X POST --post301 -H "Expect: Content-MD5" -H "Expect:
> 100-continue"-d @small.htm -v "http://<<server IP>>"
>
> The commands are identical except for the ordering of the headers.
> The IP address is the actual IP (not virtual) of a server on my local
> network. The file being POSTed (small.htm) is 4127 bytes.
>
> Using Wireshark I watched the data from each command. The first one
> shows curl sending the first part of the request (through the headers
> and final CRLF) in the packet, and no more. The 100 comes back, and
> curl sends the rest of the data. However, the 2nd command shows curl
> sending the body data in the same packet as the headers (implying that
> curl did not wait for the 100 response). Even though this is
> technically okay per the RFC, it is inconsistent behavior and does not
> permit the server to deny the request prior to the data being sent.

Internally, curl looks for manually-set headers using the Curl_checkheaders()
function and compares the header found with "100-continue". If it doesn't
match, then curl acts as though 100-continue has been overridden and operates
accordingly (i.e. without waiting). But Curl_checkheaders() only checks the
first Expect: header in its list, so if two Expect: headers exist, only the
first one determines this behaviour. The ordering of the -H options is
therefore significant to curl.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-02-15