Eran Rundstein added the comment:
Hm, it's been a while and I'm no longer sure :(
You're right - since there is no length the user will have to call read() until
he gets back ''. It's possible I forgot that assumption when speculating about
Eran Rundstein added the comment:
My pleasure.
I had no idea about the Mercurial patch, this is the first time I have
submitted a Python bug report :)
I'll have a look.
Thanks for merging the fix!
--
___
Python tracker rep...@bugs.python.org
http
Eran Rundstein added the comment:
Hello
I have attached a patch that includes a (slightly broken) fix and a test case.
Note that there is currently an unresolved issue:
If the user reads the exact amount of bytes the server sent, read() on the
socket will never have a chance to return
Eran Rundstein added the comment:
The patch is probably trivial - however I would still like some verification.
Would it be correct to call self.close() when fp.read returns ''? In case
self.length is not present, I don't see a way around this anyway. When it is
present, and fp.read returns
New submission from Eran Rundstein:
When calling HTTPResponse.read() on a response that is:
a. not chunked
b. contains no content-length header
the underlying socket (referenced by self.fp) will never get closed (through
self.close())
The offending code is at the bottom of the read() function