/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 breezy/transport/http/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2020-07-18 23:14:00 UTC
  • mfrom: (7490.40.62 work)
  • mto: This revision was merged to the branch mainline in revision 7519.
  • Revision ID: jelmer@jelmer.uk-20200718231400-jaes9qltn8oi8xss
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
227
227
    """
228
228
 
229
229
    # Some responses have bodies in which we have no interest
230
 
    _body_ignored_responses = [301, 302, 303, 307, 400, 401, 403, 404, 501]
 
230
    _body_ignored_responses = [301, 302, 303, 307, 308, 400, 401, 403, 404, 501]
231
231
 
232
232
    # in finish() below, we may have to discard several MB in the worst
233
233
    # case. To avoid buffering that much, we read and discard by chunks
879
879
 
880
880
        origin_req_host = req.origin_req_host
881
881
 
882
 
        if code in (301, 302, 303, 307):
 
882
        if code in (301, 302, 303, 307, 308):
883
883
            return Request(req.get_method(), newurl,
884
884
                           headers=req.headers,
885
885
                           origin_req_host=origin_req_host,
950
950
 
951
951
        return self.parent.open(redirected_req)
952
952
 
953
 
    http_error_301 = http_error_303 = http_error_307 = http_error_302
 
953
    http_error_301 = http_error_303 = http_error_307 = http_error_308 = http_error_302
954
954
 
955
955
 
956
956
class ProxyHandler(urllib_request.ProxyHandler):
1860
1860
 
1861
1861
        code = response.code
1862
1862
        if (request.follow_redirections is False
1863
 
                and code in (301, 302, 303, 307)):
 
1863
                and code in (301, 302, 303, 307, 308)):
1864
1864
            raise errors.RedirectRequested(request.get_full_url(),
1865
1865
                                           request.redirected_to,
1866
 
                                           is_permanent=(code == 301))
 
1866
                                           is_permanent=(code in (301, 308)))
1867
1867
 
1868
1868
        if request.redirected_to is not None:
1869
1869
            trace.mutter('redirected from: %s to: %s' % (request.get_full_url(),
1982
1982
                    abspath, range_header,
1983
1983
                    'Server return code %d' % response.status)
1984
1984
            else:
1985
 
                raise errors.InvalidHttpResponse(
1986
 
                    abspath, 'Unexpected status %d' % response.status)
 
1985
                raise errors.BadHttpRequest(abspath, response.reason)
1987
1986
        elif response.status not in (200, 206):
1988
 
            raise errors.InvalidHttpResponse(
1989
 
                abspath, 'Unexpected status %d' % response.status)
 
1987
            raise errors.UnexpectedHttpStatus(abspath, response.status)
1990
1988
 
1991
1989
        data = handle_response(
1992
1990
            abspath, response.status, response.getheader, response)
2217
2215
            'POST', abspath, body=body_bytes,
2218
2216
            headers={'Content-Type': 'application/octet-stream'})
2219
2217
        if response.status not in (200, 403):
2220
 
            raise errors.InvalidHttpResponse(
2221
 
                abspath, 'Unexpected status %d' % response.status)
 
2218
            raise errors.UnexpectedHttpStatus(abspath, response.status)
2222
2219
        code = response.status
2223
2220
        data = handle_response(
2224
2221
            abspath, code, response.getheader, response)
2232
2229
        abspath = self._remote_path(relpath)
2233
2230
        response = self.request('HEAD', abspath)
2234
2231
        if response.status not in (200, 404):
2235
 
            raise errors.InvalidHttpResponse(
2236
 
                abspath, 'Unexpected status %d' % response.status)
 
2232
            raise errors.UnexpectedHttpStatus(abspath, response.status)
2237
2233
 
2238
2234
        return response
2239
2235
 
2499
2495
            t = self._http_transport_ref()
2500
2496
            code, body_filelike = t._post(bytes)
2501
2497
            if code != 200:
2502
 
                raise errors.InvalidHttpResponse(
2503
 
                    t._remote_path('.bzr/smart'),
2504
 
                    'Expected 200 response code, got %r' % (code,))
 
2498
                raise errors.UnexpectedHttpStatus(
 
2499
                    t._remote_path('.bzr/smart'), code)
2505
2500
        except (errors.InvalidHttpResponse, errors.ConnectionReset) as e:
2506
2501
            raise errors.SmartProtocolError(str(e))
2507
2502
        return body_filelike