[Python-checkins] cpython (2.7): port to 2.7 - Minor code style improvements in http.server suggested in

senthil.kumaran python-checkins at python.org
Fri Dec 23 10:09:59 CET 2011


http://hg.python.org/cpython/rev/1b1818fee351
changeset:   74140:1b1818fee351
branch:      2.7
parent:      74137:bdec4cadea8b
user:        Senthil Kumaran <senthil at uthcode.com>
date:        Fri Dec 23 17:07:13 2011 +0800
summary:
  port to 2.7 - Minor code style improvements in http.server suggested in Issue13294.

files:
  Lib/BaseHTTPServer.py |  9 +++------
  1 files changed, 3 insertions(+), 6 deletions(-)


diff --git a/Lib/BaseHTTPServer.py b/Lib/BaseHTTPServer.py
--- a/Lib/BaseHTTPServer.py
+++ b/Lib/BaseHTTPServer.py
@@ -244,14 +244,11 @@
         self.request_version = version = self.default_request_version
         self.close_connection = 1
         requestline = self.raw_requestline
-        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
@@ -277,7 +274,7 @@
                           "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,

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list