Rev 3061: Read http responses on demand without buffering the whole body in file:///v/home/vila/src/bzr/bugs/173010/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Mon Dec 3 08:33:12 GMT 2007
At file:///v/home/vila/src/bzr/bugs/173010/
------------------------------------------------------------
revno: 3061
revision-id:v.ladeuil+lp at free.fr-20071203083306-m0kwow43u8vdrp7b
parent: v.ladeuil+lp at free.fr-20071130133919-z7go1o2zvm1cv68s
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 173010
timestamp: Mon 2007-12-03 09:33:06 +0100
message:
Read http responses on demand without buffering the whole body
response.
* bzrlib/transport/http/response.py:
New implementation of handle_response with only one RangeFile
class covering all the needs. The main purpose is to read the data
on demand instead of buffering everything at the beginning. The
main target is readv but get needs are addressed as well.
(RangeFile): Respect socket use by handling ranges on the fly and
never seeking backwards.
(HttpRangeResponse, HttpMultipartRangeResponse): Deleted.
(handle_response): The 'headers' parameter is now an HTTPMessage
containing the response headers. Stop handling 4xx error codes,
the clients do that themselves.
* bzrlib/transport/http/_urllib2_wrappers.py:
(AbstractHTTPConnection.cleanup_pipe): Renamed from 'fake_close'
the new name is more appropriate and less scary (the content is the
same though).
(HTTPDefaultErrorHandler.http_error_default): Stop handling 416
here to get a finer control in the layer above.
* bzrlib/transport/http/_urllib.py:
(HttpTransport_urllib._perform): Cleanup the httplib pipe before
each request so that clients can leave it dirty without worrying.
(HttpTransport_urllib._get): Add 416 as an expected error so that
we handle it (_urllib2_wrappers was handling it before).
(HttpTransport_urllib._get): Handle 400 and 416 errors here. Don't
bother cleaning the pipe anymore.
(HttpTransport_urllib._post, HttpTransport_urllib._head): Don't
bother cleaning the pipe anymore.
* bzrlib/transport/http/_pycurl.py:
(PyCurlTransport._get_ranged): Handle 400 and 416 errors
here. Also use HTTPMessage to replace the _extract_headers use.
(PyCurlTransport._parse_headers): New method. Create an
HTTPMessage from the raw headers provided by pycurl.
* bzrlib/transport/http/__init__.py:
(_extract_headers): Deleted. HTTPMessage is a better alternative.
(HttpTransportBase.get): Wrap the result in a StringIO since same
callers want an iterable, stop gap to make the tests pass, MUST be
fixed.
(HttpTransportBase._readv): Also catch InvalidHttpRange.
(HttpTransportBase._coalesce_readv): Indicates that only
InvalidHttpRange (not InvalidRange) can be raised from there.
* bzrlib/transport/__init__.py:
(_CoalescedOffset.__repr__): Provided by jam and lost in previous
patches.
* bzrlib/tests/test_transport_implementations.py:
(TransportTests.test_get): Switch from zip() to itertools.imap or
the transport requests are all issued before reading the files.
This works for sftp since several file-handles can be created on a
single ssh connection, for ftp since all get() are StringIO
buffered (bang head against desktop) and used to work with http
before the http response rewriting.
* bzrlib/tests/test_http_response.py: Test the new RangeFile
implementation, get rid of now useless tests. All deleted tests
have been reviewed to avoid test coverage regression.
* bzrlib/tests/HttpServer.py:
(TestingHTTPRequestHandler.get_multiple_ranges): Only one boundary
line per part should be written.
* bzrlib/errors.py:
(InvalidRange.__init__): The msg was duplicated.
(InvalidHttpRange.__init__): Add an optional 'msg' attribute.
modified:
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/tests/HttpServer.py httpserver.py-20061012142527-m1yxdj1xazsf8d7s-1
bzrlib/tests/test_http.py testhttp.py-20051018020158-b2eef6e867c514d9
bzrlib/tests/test_http_response.py test_http_response.py-20060628233143-950b2a482a32505d
bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
bzrlib/transport/__init__.py transport.py-20050711165921-4978aa7ce1285ad5
bzrlib/transport/http/__init__.py http_transport.py-20050711212304-506c5fd1059ace96
bzrlib/transport/http/_pycurl.py pycurlhttp.py-20060110060940-4e2a705911af77a6
bzrlib/transport/http/_urllib.py _urlgrabber.py-20060113083826-0bbf7d992fbf090c
bzrlib/transport/http/_urllib2_wrappers.py _urllib2_wrappers.py-20060913231729-ha9ugi48ktx481ao-1
bzrlib/transport/http/response.py _response.py-20060613154423-a2ci7hd4iw5c7fnt-1
-------------- next part --------------
Diff too large for email (1711 lines, the limit is 1000).
More information about the bazaar-commits
mailing list