Mercurial > public > mercurial-scm > hg
diff hgext/lfs/blobstore.py @ 35439:e7bb5fc4570c
lfs: add git to the User-Agent header for blob transfers
As we were trying to transition off of the non production lfs-test-server for
further experimenting, one of the problems we ran into was interoperability. A
coworker setup gitbucket[1] to act as the blob server, tested with git, and
passed it off to me. But push failed with a message saying "abort: LFS server
returns invalid JSON:", and then proceeded to dump a huge HTML page to the
screen. It turns out that it is assuming that git is the only thing that wants
to do a blob transfer, and everything else is a web browser wanting HTML.
It's only a single data point, but I suspect other things may be doing this too.
RFC7231 gives an example [2] of listing multiple products in decreasing order of
significance. Since the standard provides for this, and since it works with the
one problematic server I found, I'm just enabling this by default for a better
UX.
There's nothing significant about the version of git chosen, other than it is
the current version.
[1] https://github.com/gitbucket/gitbucket/
[2] https://tools.ietf.org/html/rfc7231#page-46
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 14 Dec 2017 13:04:08 -0500 |
parents | f98fac24b757 |
children | e333d27514b0 |
line wrap: on
line diff
--- a/hgext/lfs/blobstore.py Thu Dec 14 15:03:55 2017 -0800 +++ b/hgext/lfs/blobstore.py Thu Dec 14 13:04:08 2017 -0500 @@ -125,7 +125,8 @@ self.ui = ui baseurl, authinfo = url.authinfo() self.baseurl = baseurl.rstrip('/') - self.urlopener = urlmod.opener(ui, authinfo) + useragent = 'mercurial/%s git/2.15.1' % util.version() + self.urlopener = urlmod.opener(ui, authinfo, useragent) self.retry = ui.configint('lfs', 'retry') def writebatch(self, pointers, fromstore):