classification
Title: BaseHTTPRequestHandler.handle_expect_100() sends invalid response
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, ethan.furman, jcea, nikratio, orsenthil, python-dev
Priority: normal Keywords: patch

Created on 2013-07-28 00:36 by nikratio, last changed 2014-01-19 03:32 by python-dev. This issue is now closed.

Files
File name Uploaded Description Edit
handle_expect.diff nikratio, 2013-07-28 00:36 review
issue18574.diff nikratio, 2014-01-08 05:17 Revised patch
issue18574_rev2.patch nikratio, 2014-01-18 22:34 review
Messages (8)
msg193800 - (view) Author: Nikolaus Rath (nikratio) * Date: 2013-07-28 00:36
The handle_expect_100() implementation in BaseHTTPRequestHandler currently calls send_response_only(100) followed by flush_headers(). However, even a 1xx response is always followed by a (potentially empty) set of response headers (cf. http://tools.ietf.org/html/rfc2616#section-9.9). Therefore, clients will block waiting for an additional '\r\n' before sending the buffer.

The attached patch fixes the problem.
msg193801 - (view) Author: Nikolaus Rath (nikratio) * Date: 2013-07-28 00:38
The correct link is http://tools.ietf.org/html/rfc2616#section-10.1:

10.1 Informational 1xx

   This class of status code indicates a provisional response,
   consisting only of the Status-Line and optional headers, and is
   terminated by an empty line.
   [...]

Currently handle_expect_100() does not send this empty line.
msg207668 - (view) Author: Nikolaus Rath (nikratio) * Date: 2014-01-08 05:17
*ping*

Is there anything wrong with the patch? What do I have to do to get it applied?
msg208385 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2014-01-18 05:09
A test would be good.
msg208420 - (view) Author: Nikolaus Rath (nikratio) * Date: 2014-01-18 22:34
Thanks for looking at this! Attached is an updated patch with testcase (sorry, I thought I had included testcases everywhere).
msg208432 - (view) Author: Roundup Robot (python-dev) Date: 2014-01-19 02:51
New changeset 093ab6c02ff4 by Benjamin Peterson in branch '3.3':
fix handling of 100-continue status code (closes #18574)
http://hg.python.org/cpython/rev/093ab6c02ff4

New changeset 20a2597d6653 by Benjamin Peterson in branch 'default':
merge 3.3 (#18574)
http://hg.python.org/cpython/rev/20a2597d6653
msg208434 - (view) Author: Nikolaus Rath (nikratio) * Date: 2014-01-19 03:25
I just realized that the Misc/NEWS entry is just utterly wrong (it is talking abou the client, even though the bug is in the server), my apologies. Here's a fixed one:

- Issue #18574: Added missing newline in 100-Continue reply from
  http.server.BaseHTTPRequestHandler. Patch by Nikolaus Rath.
msg208436 - (view) Author: Roundup Robot (python-dev) Date: 2014-01-19 03:32
New changeset d00ed6e7a823 by Benjamin Peterson in branch '3.3':
correct news entry for #18574
http://hg.python.org/cpython/rev/d00ed6e7a823

New changeset cf0678c3b735 by Benjamin Peterson in branch 'default':
merge 3.3 (#18574)
http://hg.python.org/cpython/rev/cf0678c3b735
History
Date User Action Args
2014-01-19 03:32:12python-devsetmessages: + msg208436
2014-01-19 03:25:17nikratiosetmessages: + msg208434
2014-01-19 02:51:21python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg208432

resolution: fixed
stage: resolved
2014-01-18 22:34:59nikratiosetfiles: + issue18574_rev2.patch

messages: + msg208420
2014-01-18 05:09:21benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg208385
2014-01-18 02:43:54ethan.furmansetnosy: + ethan.furman
2014-01-08 05:17:27nikratiosetfiles: + issue18574.diff

messages: + msg207668
2013-08-03 04:18:11jceasetnosy: + jcea
2013-07-28 12:01:52pitrousetnosy: + orsenthil

versions: - Python 3.5
2013-07-28 00:38:05nikratiosetmessages: + msg193801
2013-07-28 00:36:27nikratiocreate