mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Minor code style improvements in http.server suggested in Issue13294.
This commit is contained in:
parent
83194f5b92
commit
3075549d53
1 changed files with 3 additions and 6 deletions
|
|
@ -271,14 +271,11 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
|
|||
self.request_version = version = self.default_request_version
|
||||
self.close_connection = 1
|
||||
requestline = str(self.raw_requestline, 'iso-8859-1')
|
||||
if requestline[-2:] == '\r\n':
|
||||
requestline = requestline[:-2]
|
||||
elif requestline[-1:] == '\n':
|
||||
requestline = requestline[:-1]
|
||||
requestline = requestline.rstrip('\r\n')
|
||||
self.requestline = requestline
|
||||
words = requestline.split()
|
||||
if len(words) == 3:
|
||||
[command, path, version] = words
|
||||
command, path, version = words
|
||||
if version[:5] != 'HTTP/':
|
||||
self.send_error(400, "Bad request version (%r)" % version)
|
||||
return False
|
||||
|
|
@ -304,7 +301,7 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
|
|||
"Invalid HTTP Version (%s)" % base_version_number)
|
||||
return False
|
||||
elif len(words) == 2:
|
||||
[command, path] = words
|
||||
command, path = words
|
||||
self.close_connection = 1
|
||||
if command != 'GET':
|
||||
self.send_error(400,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue