Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e6fdd04b
Commit
e6fdd04b
authored
Mar 27, 2009
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace duplicate code in http.server with call to http.client.parse_headers().
parent
ef9f48e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
17 deletions
+2
-17
Lib/http/client.py
Lib/http/client.py
+0
-2
Lib/http/server.py
Lib/http/server.py
+2
-15
No files found.
Lib/http/client.py
View file @
e6fdd04b
...
...
@@ -237,8 +237,6 @@ def parse_headers(fp):
to parse.
"""
# XXX: Copied from http.server.BaseHTTPRequestHandler.parse_request,
# maybe we can just call this function from there.
headers
=
[]
while
True
:
line
=
fp
.
readline
()
...
...
Lib/http/server.py
View file @
e6fdd04b
...
...
@@ -88,6 +88,7 @@ import io
import
os
import
sys
import
cgi
import
http.client
import
time
import
socket
# For gethostbyaddr()
import
shutil
...
...
@@ -312,20 +313,7 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
self
.
command
,
self
.
path
,
self
.
request_version
=
command
,
path
,
version
# Examine the headers and look for a Connection directive.
# MessageClass wants to see strings rather than bytes.
# But a TextIOWrapper around self.rfile would buffer too many bytes
# from the stream, bytes which we later need to read as bytes.
# So we read the correct bytes here, as bytes, then use StringIO
# to make them look like strings for MessageClass to parse.
headers
=
[]
while
True
:
line
=
self
.
rfile
.
readline
()
headers
.
append
(
line
)
if
line
in
(
b'
\
r
\
n
'
,
b'
\
n
'
,
b''
):
break
hfile
=
io
.
StringIO
(
b''
.
join
(
headers
).
decode
(
'iso-8859-1'
))
self
.
headers
=
email
.
parser
.
Parser
(
_class
=
self
.
MessageClass
).
parse
(
hfile
)
self
.
headers
=
http
.
client
.
parse_headers
(
self
.
rfile
)
conntype
=
self
.
headers
.
get
(
'Connection'
,
""
)
if
conntype
.
lower
()
==
'close'
:
...
...
@@ -524,7 +512,6 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
protocol_version
=
"HTTP/1.0"
# MessageClass used to parse headers
import
http.client
MessageClass
=
http
.
client
.
HTTPMessage
# Table mapping response codes to messages; entries have the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment