/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2006-07-13 19:58:22 UTC
  • mto: This revision was merged to the branch mainline in revision 1869.
  • Revision ID: john@arbash-meinel.com-20060713195822-965e2c4422506a75
cleanup pass, allow pycurl connections to be shared between transports.

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
def _extract_headers(header_file, skip_first=True):
79
79
    """Extract the mapping for an rfc822 header
80
80
 
 
81
    This is a helper function for the test suite, and for _pycurl.
 
82
    (urllib already parses the headers for us)
 
83
 
81
84
    :param header_file: A file-like object to read
82
85
    :param skip_first: HTTP headers start with the HTTP response as
83
86
                       the first line. Skip this line while parsing
216
219
        :param offsets: A list of (offset, size) tuples.
217
220
        :param return: A list or generator of (offset, data) tuples
218
221
        """
219
 
        mutter('readv of %s [%s]', relpath, offsets)
220
222
        ranges, tail_amount = self.offsets_to_ranges(offsets)
 
223
        mutter('readv of %s %s => %s tail:%s',
 
224
                relpath, offsets, ranges, tail_amount)
221
225
        code, f = self._get(relpath, ranges, tail_amount)
222
226
        for start, size in offsets:
223
227
            f.seek(start, (start < 0) and 2 or 0)
231
235
        """Turn a list of offsets and sizes into a list of byte ranges.
232
236
 
233
237
        :param offsets: A list of tuples of (start, size).  An empty list
234
 
        is not accepted.
 
238
            is not accepted.
235
239
        :param fudge_factor: Fudge together ranges that are fudge_factor
236
 
        bytes from eachother together.
 
240
            bytes apart
237
241
 
238
 
        :return: a list of byte ranges (start, end) and the amount of data
239
 
        to fetch from the tail of the file.. Adjacent ranges will be
240
 
        combined in the result.
 
242
        :return: a list of inclusive byte ranges (start, end) and the 
 
243
            amount of data to fetch from the tail of the file. 
 
244
            Adjacent ranges will be combined.
241
245
        """
242
246
        # We need a copy of the offsets, as the caller might expect it to
243
247
        # remain unsorted. This doesn't seem expensive for memory at least.
260
264
                    combined.append([start, end])
261
265
                prev_end = end
262
266
 
263
 
        mutter("combined %d offsets into %d ranges; tail access %d", len(offsets),
264
 
               len(combined), -max_negative)
265
 
 
266
267
        return combined, -max_negative
267
268
 
268
269
    def put(self, relpath, f, mode=None):