Mercurial > hg
changeset 30463:bc0def54c17d
keepalive: reorder header precedence
There are 3 sources of headers used by this function:
* The default headers defined by the URL opener
* Headers that are copied on redirects
* Headers that aren't copied on redirects
Previously, we applied the default headers from the URL
opener last. This feels wrong to me as those headers are
the most low level and something built on top of the URL
opener may wish to override them. So, this commit changes
the order to apply them with the least precedence.
While I was here, I removed a Python version test that is
no longer necessary.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 19 Nov 2016 17:11:12 -0800 |
parents | 356406ac454f |
children | e16e234b9ca3 |
files | mercurial/keepalive.py |
diffstat | 1 files changed, 3 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/keepalive.py Sat Nov 19 10:54:21 2016 -0800 +++ b/mercurial/keepalive.py Sat Nov 19 17:11:12 2016 -0800 @@ -332,10 +332,9 @@ def _start_transaction(self, h, req): # What follows mostly reimplements HTTPConnection.request() # except it adds self.parent.addheaders in the mix. - headers = req.headers.copy() - if sys.version_info >= (2, 4): - headers.update(req.unredirected_hdrs) - headers.update(self.parent.addheaders) + headers = dict(self.parent.addheaders) + headers.update(req.headers) + headers.update(req.unredirected_hdrs) headers = dict((n.lower(), v) for n, v in headers.items()) skipheaders = {} for n in ('host', 'accept-encoding'):