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
d389cb5b
Commit
d389cb5b
authored
Sep 21, 2010
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Issue1327971: HTTPResponse should expose a proper fileno attribute
parent
a6166dac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
0 deletions
+21
-0
Lib/httplib.py
Lib/httplib.py
+3
-0
Lib/test/test_httplib.py
Lib/test/test_httplib.py
+7
-0
Lib/test/test_urllib2net.py
Lib/test/test_urllib2net.py
+11
-0
No files found.
Lib/httplib.py
View file @
d389cb5b
...
...
@@ -639,6 +639,9 @@ class HTTPResponse:
amt
-=
len
(
chunk
)
return
''
.
join
(
s
)
def
fileno
(
self
):
return
self
.
fp
.
fileno
()
def
getheader
(
self
,
name
,
default
=
None
):
if
self
.
msg
is
None
:
raise
ResponseNotReady
()
...
...
Lib/test/test_httplib.py
View file @
d389cb5b
...
...
@@ -285,6 +285,13 @@ class BasicTest(TestCase):
self
.
assertEqual
(
"Basic realm=
\
"
example
\
"
"
,
resp
.
getheader
(
"www-authenticate"
))
def
test_filenoattr
(
self
):
# Just test the fileno attribute in the HTTPResponse Object.
body
=
"HTTP/1.1 200 Ok
\
r
\
n
\
r
\
n
Text"
sock
=
FakeSocket
(
body
)
resp
=
httplib
.
HTTPResponse
(
sock
)
self
.
assertTrue
(
hasattr
(
resp
,
'fileno'
),
'HTTPResponse should expose a fileno attribute'
)
class
OfflineTest
(
TestCase
):
def
test_responses
(
self
):
...
...
Lib/test/test_urllib2net.py
View file @
d389cb5b
...
...
@@ -161,6 +161,17 @@ class OtherNetworkTests(unittest.TestCase):
self
.
assertEqual
(
res
.
geturl
(),
"http://docs.python.org/glossary.html"
)
def
test_fileno
(
self
):
req
=
urllib2
.
Request
(
"http://www.python.org"
)
opener
=
urllib2
.
build_opener
()
res
=
opener
.
open
(
req
)
try
:
res
.
fileno
()
except
AttributeError
:
self
.
fail
(
"HTTPResponse object should return a valid fileno"
)
finally
:
res
.
close
()
def
_test_urls
(
self
,
urls
,
handlers
,
retry
=
True
):
import
time
import
logging
...
...
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