Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'cpython': 0.05; 'elif': 0.05; 'handler': 0.05; '338': 0.09; '340': 0.09; 'defines': 0.09; 'http': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:page.': 0.09; 'to)': 0.09; 'itself.': 0.14; '(1,': 0.16; '331': 0.16; '332': 0.16; '333': 0.16; '334': 0.16; '335': 0.16; '336': 0.16; '337': 0.16; '339': 0.16; '570': 0.16; 'directive': 0.16; 'piotr': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject: \n ': 0.16; 'subject:after': 0.16; 'titled': 0.16; 'url:file': 0.16; 'wrote:': 0.18; 'module': 0.19; 'slightly': 0.19; '(in': 0.22; 'header:User- Agent:1': 0.23; 'headers': 0.24; 'question': 0.24; 'sort': 0.25; 'second': 0.26; 'post': 0.26; 'subject:/': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'code': 0.31; '"")': 0.31; 'doc': 0.31; 'loading': 0.31; 'class': 0.32; 'checked': 0.32; 'says': 0.33; 'url:python': 0.33; 'skip:# 10': 0.33; 'subject:the': 0.34; "i'd": 0.34; 'subject:with': 0.35; "can't": 0.35; 'problem.': 0.35; 'test': 0.35; 'but': 0.35; 'version': 0.36; 'false': 0.36; 'method': 0.36; 'url:org': 0.36; 'should': 0.36; 'so,': 0.37; 'server': 0.38; 'branch': 0.38; 'skip:m 40': 0.38; 'handle': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'expect': 0.39; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'received:org': 0.40; 'received:173': 0.61; 'simple': 0.61; 'such': 0.63; 'url:http': 0.64; 'linked': 0.65; 'charset:windows-1252': 0.65; 'hang': 0.67; 'believe': 0.68; 'default': 0.69; 'attention': 0.75; '3.3.1': 0.84; 'isn\x92t': 0.84; 'received:fios.verizon.net': 0.84; 'url:cpython': 0.84; 'subject:skip:S 20': 0.91; 'task,': 0.91; 'examine': 0.93; 'hand,': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Jan Reedy Subject: Re: SimpleHTTPRequestHandler used with HTTP/1.1 hangs after the second resource on a page. Date: Fri, 12 Apr 2013 18:21:33 -0400 References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 56 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365805306 news.xs4all.nl 2675 [2001:888:2000:d::a6]:51043 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43489 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