~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Ian Clatworthy
  • Date: 2007-07-03 07:03:32 UTC
  • mfrom: (2520.2.3 115209)
  • mto: This revision was merged to the branch mainline in revision 2575.
  • Revision ID: ian.clatworthy@internode.on.net-20070703070332-45j7qw8z03fnulav
(Vincent Ladeuil) Fix #115209 - Unable to handle http code 400: Bad Request When issuing too many ranges

Show diffs side-by-side

added added

removed removed

Lines of Context:
113
113
 
114
114
        return response
115
115
 
116
 
    def _get(self, relpath, ranges, tail_amount=0):
 
116
    def _get(self, relpath, offsets, tail_amount=0):
117
117
        """See HttpTransport._get"""
118
118
 
119
119
        abspath = self._real_abspath(relpath)
120
120
        headers = {}
121
 
        if ranges or tail_amount:
122
 
            range_header = self.attempted_range_header(ranges, tail_amount)
 
121
        accepted_errors = [200, 404]
 
122
        if offsets or tail_amount:
 
123
            range_header = self._attempted_range_header(offsets, tail_amount)
123
124
            if range_header is not None:
 
125
                accepted_errors.append(206)
 
126
                accepted_errors.append(400)
124
127
                bytes = 'bytes=' + range_header
125
128
                headers = {'Range': bytes}
126
129
 
127
 
        request = Request('GET', abspath, None, headers)
 
130
        request = Request('GET', abspath, None, headers,
 
131
                          accepted_errors=accepted_errors)
128
132
        response = self._perform(request)
129
133
 
130
134
        code = response.code
157
161
        Performs the request and leaves callers handle the results.
158
162
        """
159
163
        abspath = self._real_abspath(relpath)
160
 
        request = Request('HEAD', abspath)
 
164
        request = Request('HEAD', abspath,
 
165
                          accepted_errors=[200, 404])
161
166
        response = self._perform(request)
162
167
 
163
168
        self._connection.fake_close()
172
177
        if code == 200: # "ok",
173
178
            return True
174
179
        else:
175
 
            assert(code == 404, 'Only 200 or 404 are correct')
176
180
            return False
177
181
 
178
182