Merge lp:~jelmer/brz-git/user-agent into lp:brz-git

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 1837
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz-git/user-agent
Merge into: lp:brz-git
Diff against target: 25 lines (+6/-1)
1 file modified
__init__.py (+6/-1)
To merge this branch: bzr merge lp:~jelmer/brz-git/user-agent
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+341183@code.launchpad.net

Commit message

Override user-agent to start with "git/" when talking to github.

Description of the change

Override user-agent to start with "git/" when talking to github.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '__init__.py'
2--- __init__.py 2018-02-27 18:43:26 +0000
3+++ __init__.py 2018-03-08 23:09:34 +0000
4@@ -54,6 +54,7 @@
5 gettext = translation.gettext
6
7 from ... import (
8+ __version__ as breezy_version,
9 errors as bzr_errors,
10 trace,
11 )
12@@ -163,8 +164,12 @@
13 base_url, _ = urlutils.split_segment_parameters(transport.external_url())
14 url = urlutils.join(base_url, "info/refs") + "?service=git-upload-pack"
15 from ...transport.http._urllib import HttpTransport_urllib, Request
16+ headers = {"Content-Type": "application/x-git-upload-pack-request"}
17+ if "github.com" in url:
18+ # GitHub requires we lie. https://github.com/dulwich/dulwich/issues/562
19+ headers["User-agent"] = "git/Breezy/%s" % breezy_version
20 req = Request('GET', url, accepted_errors=[200, 403, 404, 405],
21- headers={"Content-Type": "application/x-git-upload-pack-request"})
22+ headers=headers)
23 req.follow_redirections = True
24 resp = transport._perform(req)
25 if resp.code in (404, 405):

Subscribers

People subscribed via source and target branches

to all changes: