# HG changeset patch # User Gregory Szorc # Date 1479604272 28800 # Node ID bc0def54c17d435df0524e3b8fc33ed8e13f097b # Parent 356406ac454f504a1b9265e26db04dff57c36efe 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. diff -r 356406ac454f -r bc0def54c17d mercurial/keepalive.py --- 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'):