~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin
  • Date: 2012-07-28 15:26:22 UTC
  • mto: This revision was merged to the branch mainline in revision 6546.
  • Revision ID: gzlist@googlemail.com-20120728152622-wkjruul7dtg6c0ts
Add release notes

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    """A wrapper around the http socket containing the result of a GET request.
39
39
 
40
40
    Only read() and seek() (forward) are supported.
41
 
 
42
41
    """
43
42
    def __init__(self, path, infile):
44
43
        """Constructor.
72
71
        self._pos += len(data)
73
72
        return data
74
73
 
75
 
    def __iter__(self):
76
 
        while True:
77
 
            line = self.readline()
78
 
            if not line:
79
 
                return
80
 
            yield line
81
 
 
82
74
    def tell(self):
83
75
        return self._pos
84
76
 
289
281
                    % (size, self._start, self._size))
290
282
 
291
283
        # read data from file
292
 
        buf = StringIO()
 
284
        buffer = StringIO()
293
285
        limited = size
294
286
        if self._size > 0:
295
287
            # Don't read past the range definition
296
288
            limited = self._start + self._size - self._pos
297
289
            if size >= 0:
298
290
                limited = min(limited, size)
299
 
        osutils.pumpfile(self._file, buf, limited, self._max_read_size)
300
 
        data = buf.getvalue()
 
291
        osutils.pumpfile(self._file, buffer, limited, self._max_read_size)
 
292
        data = buffer.getvalue()
301
293
 
302
294
        # Update _pos respecting the data effectively read
303
295
        self._pos += len(data)