Roundup Robot added the comment:
New changeset 49017c391564 by Kristján Valur Jónsson in branch 'default':
Issue #19009
http://hg.python.org/cpython/rev/49017c391564
--
nosy: +python-dev
___
Python tracker rep...@bugs.python.org
Kristján Valur Jónsson added the comment:
Sure. If there are issues we'll just reopen. Closing.
--
resolution: - fixed
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19009
Antoine Pitrou added the comment:
If this is committed, should the issue be closed?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19009
___
___
Serhiy Storchaka added the comment:
LGTM.
--
stage: patch review - commit review
versions: +Python 3.5 -Python 3.4
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19009
___
Kristján Valur Jónsson added the comment:
A new patch set, in response to Serhiy's comments on Rietveld.
--
Added file: http://bugs.python.org/file31884/httpresponse.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19009
Serhiy Storchaka added the comment:
Kristján, did you notice my comments on Rietveld?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19009
___
Kristján Valur Jónsson added the comment:
Ah no actually. Thanks . I'll respond soon.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19009
___
Kristján Valur Jónsson added the comment:
Ok, Here is a new patch.
We now inherit from BufferedIOBase. We must implement read(amt) ourselves,
since the base class does not do it.
I was wrong about the final chunk, it is in fact 0\r\n. A final \r\n is then
added to signal the end of the
Serhiy Storchaka added the comment:
After adding read1() and peek() what stop us from inheriting HTTPResponse from
BufferedIOBase?
I suggest split _read1_or_peek_chunked() by two parts. First part calculates n
bounded by chunk_left (it can read the next chunk size and close a connection
if
Kristján Valur Jónsson added the comment:
Ok, I have refactored this a bit.
A separate new function now takes care of the reading of chunk-header and tail.
This simplifies the other functions.
I'm not sure what you mean by inheriting from the buffered class. Do we gain
anything by doing
Serhiy Storchaka added the comment:
A separate new function now takes care of the reading of chunk-header and
tail. This simplifies the other functions.
Good. It is even better than I expected.
Do we gain anything by doing that, would it change the code? or would it
merely be for the
Antoine Pitrou added the comment:
Note for the different interpretation of the final chunk:
Chunked encoding allows for adding headers after the final chunk.
This is what _read_and_discard_trailer() does, but discarding the
trailing headers. So, if support is ever added for reading those
Kristján Valur Jónsson added the comment:
Ok, I can change the base class inheritance and see if it changes things.
Note for the different interpretation of the final chunk:
Chunked encoding allows for adding headers after the final chunk. This is what
_read_and_discard_trailer() does, but
Kristján Valur Jónsson added the comment:
Ok, I can make it resilient. I was just pointing out that resilience in the
face of RFC violations can be a bad thing. E.g. Internet explorer and how they
allowed internet servers of the world to be lax in how they served their data.
No matter, I can
Antoine Pitrou added the comment:
Ok, I can make it resilient. I was just pointing out that resilience
in the face of RFC violations can be a bad thing. E.g. Internet
explorer and how they allowed internet servers of the world to be lax
in how they served their data.
I'm afraid the ship
Kristján Valur Jónsson added the comment:
Very well, let's support both then :)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19009
___
___
Kristján Valur Jónsson added the comment:
Ok, I'm adding a more comprehensive patch. It adds support for
peek, readline, and read1 for both regular and chunked responses.
readline falls back to IOBase.readline for chunked, which again makes use of
peek() for performance.
read1() is available
New submission from Kristján Valur Jónsson:
Some applications require reading http response data in long polls as it
becomes available. This is used, e.g. to receive notifications over a HTTP
stream.
Using response.read(large_buffer) is not possible because this will attempt to
fullfill the
Antoine Pitrou added the comment:
This sounds ok on the principle. I suppose one can't simply wrap the fp
inside a BufferedReader?
I think it would be good to add tests for the peek() implementation, though.
--
nosy: +orsenthil, pitrou, serhiy.storchaka
stage: - patch review
versions:
Kristján Valur Jónsson added the comment:
The problem is that self.fp is already a Buffered stream, and such streams are
documented to have their read() and readinto() calls make multiple system calls
to fullfill the request.
My original goal was actually to make response.read(amt) not try to
Antoine Pitrou added the comment:
My original goal was actually to make response.read(amt) not try to
make multiple read() calls, so that one could have other delimiters
than newline. It is simple for the chunked case, but I don't know
how to bypass it for response.fp, since it is already a
R. David Murray added the comment:
See also issue 13541?
--
nosy: +r.david.murray
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19009
___
___
Kristján Valur Jónsson added the comment:
Intersting. I didn't know about that. My excuse is that I never use 3.x except
when I'm porting some CCP enhancements for cpython.
Here's a thought: HTTPResponse inherits from RawIOBase. Only the BufferedIO
classes have read1() and are documented
Kristján Valur Jónsson added the comment:
I should add, I fully support the use case that response.read(amt=None) needs
to read to the end of the response. It is only the read(amt=bufsize) use case
I'm thinking of, and that could be handled with a read1() method.
--
24 matches
Mail list logo