-
Committer:
Vincent Ladeuil
-
Date:
2007-12-03 08:33:06 UTC
-
mto:
(2929.3.16 https)
(3097.2.1 trunk)
-
mto:
This revision was merged to the branch mainline in
revision
3099.
-
Revision ID:
v.ladeuil+lp@free.fr-20071203083306-m0kwow43u8vdrp7b
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.