/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/git/__init__.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2019-05-28 23:50:18 UTC
  • mfrom: (7296.2.9 urllib3-like)
  • Revision ID: breezy.the.bot@gmail.com-20190528235018-wpu2geti8rd2t9ji
Use a more urllib3-like API for HTTP requests.

Merged from https://code.launchpad.net/~jelmer/brz/urllib3-like/+merge/367618

Show diffs side-by-side

added added

removed removed

Lines of Context:
156
156
        url.user = url.quoted_user = None
157
157
        url.password = url.quoted_password = None
158
158
        url = urlutils.join(str(url), "info/refs") + "?service=git-upload-pack"
159
 
        from ..transport.http import Request
160
159
        headers = {"Content-Type": "application/x-git-upload-pack-request",
161
160
                   "Accept": "application/x-git-upload-pack-result",
162
161
                   }
163
 
        req = Request('GET', url, accepted_errors=[200, 403, 404, 405],
164
 
                      headers=headers)
165
162
        (scheme, user, password, host, port,
166
 
         path) = urlutils.parse_url(req.get_full_url())
 
163
         path) = urlutils.parse_url(url)
167
164
        if host == "github.com":
168
165
            # GitHub requires we lie.
169
166
            # https://github.com/dulwich/dulwich/issues/562
171
168
        elif host == "bazaar.launchpad.net":
172
169
            # Don't attempt Git probes against bazaar.launchpad.net; pad.lv/1744830
173
170
            raise brz_errors.NotBranchError(transport.base)
174
 
        resp = transport._perform(req)
175
 
        if resp.code in (404, 405):
 
171
        resp = transport.request('GET', url, headers=headers)
 
172
        if resp.status in (404, 405):
176
173
            raise brz_errors.NotBranchError(transport.base)
 
174
        else:
 
175
            raise errors.InvalidHttpResponse(
 
176
                url, 'Unable to handle http code %d' % resp.status)
 
177
 
177
178
        headers = resp.headers
178
179
        ct = headers.get("Content-Type")
179
180
        if ct is None: