Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43489
| From | Terry Jan Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: SimpleHTTPRequestHandler used with HTTP/1.1 hangs after the second resource on a page. |
| Date | 2013-04-12 18:21 -0400 |
| References | <bf0b6bfd-9226-4bb4-9c77-3ec418a154a0@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.540.1365805306.3114.python-list@python.org> (permalink) |
On 4/12/2013 4:46 PM, Piotr Dobrogost wrote:
> Hi!
>
> I'd like to bring your attention to the question titled "Use HTTP/1.1
> with SimpleHTTPRequestHandler" at
> http://stackoverflow.com/q/15839718/95735 which reads; "When I use
I find the doc slightly confusing. The SO code uses BaseHTTPServer. The
doc says "Usually, this module isn’t used directly," On the other hand,
SimpleHTTPServer only defines a request handler and not a server itself.
> HTTP/1.1 with SimpleHTTPRequestHandler, loading a page that pulls in
> other resources will hang after the second resource." and there's a
What does 'hang' mean? Does the page get displayed? If so,
server.serve_forever is supposes to 'hang'.
> tiny test showing the problem. It's hard to believe that
> SimpleHTTPServer doesn't handle such a simple task, does it? If I
> checked correctly code is stuck in handle_one_request() method at
> line 370 of server.py
> (http://hg.python.org/cpython/file/d9893d13c628/Lib/http/server.py#l370)
> but I can't see what's wrong. Any ideas?
The SO post says
class MyRequestHandler(SimpleHTTPRequestHandler):
#protocol_version = "HTTP/1.0" # works
protocol_version = "HTTP/1.1" # hangs
so this should be some sort of clue. The code says
569 # The version of the HTTP protocol we support.
570 # Set this to HTTP/1.1 to enable automatic keepalive
571 protocol_version = "HTTP/1.0"
The only substantive code I found using protocol_version (in the CPython
default branch you linked to) is
300 if version_number >= (1, 1) and self.protocol_version >= "HTTP/1.1":
301 self.close_connection = 0
331 elif (conntype.lower() == 'keep-alive' and
332 self.protocol_version >= "HTTP/1.1"):
333 self.close_connection = 0
334 # Examine the headers and look for an Expect directive
335 expect = self.headers.get('Expect', "")
336 if (expect.lower() == "100-continue" and
337 self.protocol_version >= "HTTP/1.1" and
338 self.request_version >= "HTTP/1.1"):
339 if not self.handle_expect_100():
340 return False
I would re-test with the recently released 3.3.1 (and/or 2.7.4) to make
sure nothing has changed
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
SimpleHTTPRequestHandler used with HTTP/1.1 hangs after the second resource on a page. Piotr Dobrogost <p@google-groups-2013.dobrogost.net> - 2013-04-12 13:46 -0700
Re: SimpleHTTPRequestHandler used with HTTP/1.1 hangs after the second resource on a page. Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-12 18:21 -0400
Re: SimpleHTTPRequestHandler used with HTTP/1.1 hangs after the second resource on a page. Piotr Dobrogost <p@google-groups-2013.dobrogost.net> - 2013-04-13 10:21 -0700
Re: SimpleHTTPRequestHandler used with HTTP/1.1 hangs after the second resource on a page. Piotr Dobrogost <p@google-groups-2013.dobrogost.net> - 2013-04-13 10:21 -0700
csiph-web