~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/_pycurl.py

  • Committer: Vincent Ladeuil
  • Date: 2007-06-12 14:48:57 UTC
  • mto: (2574.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2575.
  • Revision ID: v.ladeuil+lp@free.fr-20070612144857-1swhz5c3qo8n76l8
First step to fix #115209 use _coalesce_offsets like other transports.

* bzrlib/transport/http/__init__.py:
(HttpTransportBase._bytes_to_read_before_seek): Setting it to 512
to minimize additional bytes transferred but still reducing number
of ranges.
(HttpTransportBase.readv): _coalesce_offsets does a better job
than offset_to_ranges/ Reduce code duplication too.
(HttpTransportBase.offsets_to_ranges): Deprecated.
(HttpTransportBase._attempted_range_header): Made private. Adapted
to offsets.
(HttpTransportBase._range_header): Made private. Adapted to
offsets.

* bzrlib/transport/http/_urllib.py:
(HttpTransport_urllib._get): s/ranges/offsets/

* bzrlib/transport/http/_pycurl.py:
(PyCurlTransport._get, PyCurlTransport._get_ranged): s/ranges/offsets/

* bzrlib/tests/__init__.py:
(Transport._coalesce_offsets): Fix minor typo.

* bzrlib/tests/test_http.py:
(TestOffsets): Deleted. We rely on Transport._coalesce_offsets
only now.
(TestRangeHeader.check_header): Convert ranges to offets and use
Transport._coalesce_offsets.
(TestRangeHeader.test_range_header_single): Use tuples not lists !
(TestRanges._file_contents): Convert ranges to offets and use
Transport._coalesce_offsets. And fix indentation too.
(TestRanges._file_tail): Fix indentation.
(TestRanges.test_range_header): Use _file_contents so that we can
still use ranges.

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
        else:
137
137
            self._raise_curl_http_error(curl)
138
138
 
139
 
    def _get(self, relpath, ranges, tail_amount=0):
 
139
    def _get(self, relpath, offsets, tail_amount=0):
140
140
        # This just switches based on the type of request
141
 
        if ranges is not None or tail_amount not in (0, None):
142
 
            return self._get_ranged(relpath, ranges, tail_amount=tail_amount)
 
141
        if offsets is not None or tail_amount not in (0, None):
 
142
            return self._get_ranged(relpath, offsets, tail_amount=tail_amount)
143
143
        else:
144
144
            return self._get_full(relpath)
145
145
 
189
189
 
190
190
        return code, data
191
191
 
192
 
    def _get_ranged(self, relpath, ranges, tail_amount):
 
192
    def _get_ranged(self, relpath, offsets, tail_amount):
193
193
        """Make a request for just part of the file."""
194
194
        curl = self._curl
195
195
        abspath, data, header = self._setup_get_request(curl, relpath)
196
196
 
197
 
        range_header = self.attempted_range_header(ranges, tail_amount)
 
197
        range_header = self._attempted_range_header(offsets, tail_amount)
198
198
        if range_header is None:
199
199
            # Forget ranges, the server can't handle them
200
200
            return self._get_full(relpath)