[issue19052] Python's CGIHTTPServer does not handle Expect: 100-continue gracefully which results in some Post requests being handled slowly.

2013-09-19 Thread Joseph Warren

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



[issue19052] Python's CGIHTTPServer does not handle Expect: 100-continue gracefully which results in some Post requests being handled slowly.

2013-09-19 Thread Joseph Warren

Joseph Warren added the comment:

Cheers, would you suggest I submit a patch then?

Also what version of python should I do this against? I've been working with 
2.7, but the issue still exists in 3.* and I can conveniently work against 
3.2.3-7, and less conveniently work against other versions.

--

___
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



[issue19052] Python's CGIHTTPServer does not handle Expect: 100-continue gracefully which results in some Post requests being handled slowly.

2013-09-19 Thread Joseph Warren

Joseph Warren added the comment:

Issue1346874 seems similar, but is talking about a failure to handle 100 
Continue responses sent by a server to the client, this issue is in server 
code, and is a failure of BaseHttpServer to send 100 Continue responses to a 
client which expects them.

Please tell me if I'm mistaken/not making sense.

--

___
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



[issue19052] Python's CGIHTTPServer does not handle Expect: 100-continue gracefully which results in some Post requests being handled slowly.

2013-09-19 Thread Joseph Warren

Joseph Warren added the comment:

Have downloaded an up to date version of Python to develop with, and found that 
this issue had been fixed in it. This seems to have been done in changeset:   
65028:7add45bcc9c6

changeset:   65028:7add45bcc9c6
user:Senthil Kumaran orsent...@gmail.com
date:Thu Sep 30 06:09:18 2010 +
summary: Issue1491 - BaseHTTPServer incorrectly implements response code 100

This change does not seem to appear in 2.7 , and could be converted to work 
with this, however failing this, this issue can probably be closed.

I appologise for not spotting this earlier.

--

___
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



[issue19052] Python's CGIHTTPServer does not handle Expect: 100-continue gracefully which results in some Post requests being handled slowly.

2013-09-19 Thread Joseph Warren

Joseph Warren added the comment:

Sorry, this change does appear in 2.7.* I was looking at the wrong mercurial Tag

--

___
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



[issue19052] Python's CGIHTTPServer does not handle Expect: 100-continue gracefully which results in some Post requests being handled slowly.

2013-09-19 Thread Joseph Warren

Changes by Joseph Warren hungryjoe.war...@gmail.com:


--
resolution:  - duplicate
status: open - closed

___
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