diff mercurial/wireprotoserver.py @ 36868:ec0af9c59270

hgweb: use a multidict for holding query string parameters My intention with refactoring the WSGI code was to make it easier to read. I initially wanted to vendor and use WebOb, because it seems to be a pretty reasonable abstraction layer for WSGI. However, it isn't using relative imports and I didn't want to deal with the hassle of patching it. But that doesn't mean we can't use good ideas from WebOb. WebOb has a "multidict" data structure for holding parsed query string and POST form data. It quacks like a dict but allows you to store multiple values for each key. It offers mechanisms to return just one value, all values, or return 1 value asserting that only 1 value is set. I quite like its API. This commit implements a read-only "multidict" in the spirit of WebOb's multidict. We replace the query string attributes of our parsed request with an instance of it. Differential Revision: https://phab.mercurial-scm.org/D2776
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 10 Mar 2018 12:35:38 -0800
parents a88d68dc3ee8
children a755fd3b7146
line wrap: on
line diff
--- a/mercurial/wireprotoserver.py	Sat Mar 10 11:23:05 2018 -0800
+++ b/mercurial/wireprotoserver.py	Sat Mar 10 12:35:38 2018 -0800
@@ -79,7 +79,7 @@
         return [data[k] for k in keys]
 
     def _args(self):
-        args = util.rapply(pycompat.bytesurl, self._wsgireq.form.copy())
+        args = self._req.qsparams.asdictoflists()
         postlen = int(self._req.headers.get(b'X-HgArgs-Post', 0))
         if postlen:
             args.update(urlreq.parseqs(
@@ -170,10 +170,10 @@
     # HTTP version 1 wire protocol requests are denoted by a "cmd" query
     # string parameter. If it isn't present, this isn't a wire protocol
     # request.
-    if 'cmd' not in req.querystringdict:
+    if 'cmd' not in req.qsparams:
         return False
 
-    cmd = req.querystringdict['cmd'][0]
+    cmd = req.qsparams['cmd']
 
     # The "cmd" request parameter is used by both the wire protocol and hgweb.
     # While not all wire protocol commands are available for all transports,