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
22b3a49d
Commit
22b3a49d
authored
Nov 13, 2002
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix SF bug #637789: Handle Proxy-Connection header.
Also, remove unused local variable noted by pychecker.
parent
33635aaf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
15 deletions
+25
-15
Lib/httplib.py
Lib/httplib.py
+25
-15
No files found.
Lib/httplib.py
View file @
22b3a49d
...
...
@@ -169,7 +169,6 @@ class HTTPMessage(mimetools.Message):
# for http and/or for repeating headers
# It's a continuation line.
list
.
append
(
line
)
x
=
self
.
dict
[
headerseen
]
+
"
\
n
"
+
line
.
strip
()
self
.
addcontinue
(
headerseen
,
line
.
strip
())
continue
elif
self
.
iscomment
(
line
):
...
...
@@ -311,20 +310,7 @@ class HTTPResponse:
self
.
chunked
=
0
# will the connection close at the end of the response?
conn
=
self
.
msg
.
getheader
(
'connection'
)
if
conn
:
conn
=
conn
.
lower
()
# a "Connection: close" will always close the connection. if we
# don't see that and this is not HTTP/1.1, then the connection will
# close unless we see a Keep-Alive header.
self
.
will_close
=
conn
.
find
(
'close'
)
!=
-
1
or
\
(
self
.
version
!=
11
and
\
not
self
.
msg
.
getheader
(
'keep-alive'
)
)
else
:
# for HTTP/1.1, the connection will always remain open
# otherwise, it will remain open IFF we see a Keep-Alive header
self
.
will_close
=
self
.
version
!=
11
and
\
not
self
.
msg
.
getheader
(
'keep-alive'
)
self
.
will_close
=
self
.
_check_close
()
# do we have a Content-Length?
# NOTE: RFC 2616, S4.4, #3 says we ignore this if tr_enc is "chunked"
...
...
@@ -351,6 +337,30 @@ class HTTPResponse:
self
.
length
is
None
:
self
.
will_close
=
1
def
_check_close
(
self
):
if
self
.
version
==
11
:
# An HTTP/1.1 proxy is assumed to stay open unless
# explicitly closed.
conn
=
self
.
msg
.
getheader
(
'connection'
)
if
conn
and
conn
.
lower
().
find
(
"close"
)
>=
0
:
return
True
return
False
# An HTTP/1.0 response with a Connection header is probably
# the result of a confused proxy. Ignore it.
# For older HTTP, Keep-Alive indiciates persistent connection.
if
self
.
msg
.
getheader
(
'keep-alive'
):
return
False
# Proxy-Connection is a netscape hack.
pconn
=
self
.
msg
.
getheader
(
'proxy-connection'
)
if
pconn
and
pconn
.
lower
().
find
(
"keep-alive"
)
>=
0
:
return
False
# otherwise, assume it will close
return
True
def
close
(
self
):
if
self
.
fp
:
self
.
fp
.
close
()
...
...
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