New submission from Joseph Warren:

I will add as a disclaimer to this bug report that I am relatively new to both 
the http spec, and Python programming, so I may have completely misunderstood 
something.

When I make a post request with some data (using libCurl), It sends the headers 
first, including one header, "Expect: 100-continue" and then waits for around a 
second, or until receiving a "100 Continue" response, before sending the rest 
of the data. (I have attached WireShark capture data as html to show this, I've 
also attached a dump showing how Apache behaves given the same request). 

This means that when I make such a request to a CGI script, hosted using 
CGIHTTPServer, and the script tries to read in the data, (for instance, using 
cgi.FieldStorage() ). Then the CGI script takes around a second to parse the 
data, since it hasn't been sent yet.

I currently have a work-around for this, which is to override 
CGIHTTPRequestHandler, and have it send a "100 Continue" response before doing 
anything else. A dump showing this is attached, this makes the connection much 
faster. This is fine for my application, as all CGI requests will be made in 
the same way, However it is not a general solution. 

The W3C, when defining Expect Headers, state (taken from 
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html);

A server that does not understand or is unable to comply with any of the 
expectation values in the Expect field of a request MUST respond with 
appropriate error status. The server MUST respond with a 417 (Expectation 
Failed) status if any of the expectations cannot be met or, if there are other 
problems with the request, some other 4xx status. 


I would like to offer to implement handling of the Expect header in 
BaseHTTPServer, however I would like some feedback before doing this, and to 
check that the current behaviour is not intended for some reason.

This change would make CGIHTTPServer much faster in my use case, and I suspect 
it would help other people.

----------
components: Library (Lib)
files: Wireshark_Captures.html
messages: 198084
nosy: Joseph.Warren
priority: normal
severity: normal
status: open
title: Python's CGIHTTPServer does not handle Expect: 100-continue gracefully 
which results in some Post requests being handled slowly.
type: performance
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 
3.4, Python 3.5
Added file: http://bugs.python.org/file31818/Wireshark_Captures.html

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19052>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to