diff mercurial/wireprotoserver.py @ 36853:ed0456fde625

hgweb: handle CONTENT_LENGTH PEP 3333 says CONTENT_LENGTH may be set. I /think/ WSGI servers are allowed to invent this key even if the client didn't send it. We had code in wireprotoserver looking for this key. So let's just automagically convert this key to an HTTP request header when parsing the request. Differential Revision: https://phab.mercurial-scm.org/D2744
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 10 Mar 2018 10:45:12 -0800
parents 14f70c44af6c
children 16292bbda39c
line wrap: on
line diff
--- a/mercurial/wireprotoserver.py	Thu Mar 08 16:38:01 2018 -0800
+++ b/mercurial/wireprotoserver.py	Sat Mar 10 10:45:12 2018 -0800
@@ -91,10 +91,9 @@
         return args
 
     def forwardpayload(self, fp):
-        if b'Content-Length' in self._req.headers:
-            length = int(self._req.headers[b'Content-Length'])
-        else:
-            length = int(self._wsgireq.env[r'CONTENT_LENGTH'])
+        # Existing clients *always* send Content-Length.
+        length = int(self._req.headers[b'Content-Length'])
+
         # If httppostargs is used, we need to read Content-Length
         # minus the amount that was consumed by args.
         length -= int(self._req.headers.get(b'X-HgArgs-Post', 0))