/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/_urllib2_wrappers.py

  • Committer: Vincent Ladeuil
  • Date: 2008-01-02 14:13:55 UTC
  • mto: (3159.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 3161.
  • Revision ID: v.ladeuil+lp@free.fr-20080102141355-k20yfjo6i1dasuny
Fix #179368 by keeping the current range hint on ShortReadvErrors.

* response.py:
(RangeFile._checked_read): Avoid huge buffering when huge seeks
are required.

* _urllib2_wrappers.py:
(Response.finish): Check for end-of-file or we'll loop if the
server lied about Content-Length.

* __init__.py:
(HttpTransportBase._readv): When a ShortReadvError occurs, try
again, staying in multiple range mode and degrades only if the
error occurs again for the same offset.

* test_http_response.py:
(TestRangeFileMultipleRanges): Add a test to exercise the buffer
overflow protection code.

* test_http.py:
(TestMultipleRangeWithoutContentLengthServer): Emulate lighttpd
behavior regarding bug #179368.

Show diffs side-by-side

added added

removed removed

Lines of Context:
134
134
        if not self.isclosed():
135
135
            # Make sure nothing was left to be read on the socket
136
136
            pending = 0
137
 
            while self.length and self.length > self._discarded_buf_size:
 
137
            data = True
 
138
            while (data and self.length
 
139
                   and self.length > self._discarded_buf_size):
138
140
                data = self.read(self._discarded_buf_size)
139
141
                pending += len(data)
140
 
            if self.length:
 
142
            if data and self.length:
141
143
                data = self.read(self.length)
142
144
                pending += len(data)
143
145
            if pending:
144
 
                trace.mutter(
145
 
                    "%s bytes left on the HTTP socket",
146
 
                    pending)
 
146
                trace.mutter("%s bytes left on the HTTP socket", pending)
147
147
            self.close()
148
148
        return pending
149
149