[PATCH] do not replace the request header names with lower case

domruf dominikruf at gmail.com
Fri May 23 05:57:39 CDT 2014


# HG changeset patch
# User domruf <dominikruf at gmail.com>
# Date 1400792192 -7200
#      Thu May 22 22:56:32 2014 +0200
# Branch stable
# Node ID 023ef1daa66809071a1d2261bb548404e7560368
# Parent  54d7657d7d1e6a62315eea53f4498657e766bb60
do not replace the request header names with lower case

If a webserver expects a header in a certain case the request might fail.
i.e. if a (not so well writen) authentication module only accepts
"Authorization" and fails with "authorization"

diff -r 54d7657d7d1e -r 023ef1daa668 mercurial/keepalive.py
--- a/mercurial/keepalive.py	Mon May 05 16:54:15 2014 +0200
+++ b/mercurial/keepalive.py	Thu May 22 22:56:32 2014 +0200
@@ -329,19 +329,19 @@
         if sys.version_info >= (2, 4):
             headers.update(req.unredirected_hdrs)
         headers.update(self.parent.addheaders)
-        headers = dict((n.lower(), v) for n, v in headers.items())
+        headersnames = dict((n.lower(), v) for n, v in headers.items())
         skipheaders = {}
         for n in ('host', 'accept-encoding'):
-            if n in headers:
+            if n in headersnames:
                 skipheaders['skip_' + n.replace('-', '_')] = 1
         try:
             if req.has_data():
                 data = req.get_data()
                 h.putrequest('POST', req.get_selector(), **skipheaders)
-                if 'content-type' not in headers:
+                if 'content-type' not in headersnames:
                     h.putheader('Content-type',
                                 'application/x-www-form-urlencoded')
-                if 'content-length' not in headers:
+                if 'content-length' not in headersnames:
                     h.putheader('Content-length', '%d' % len(data))
             else:
                 h.putrequest('GET', req.get_selector(), **skipheaders)




--
View this message in context: http://mercurial.808500.n3.nabble.com/PATCH-do-not-replace-the-request-header-names-with-lower-case-tp4010751p4010765.html
Sent from the Development mailing list archive at Nabble.com.


More information about the Mercurial-devel mailing list