wireproto: add config knob for http header length limit
authorMike Edgar <adgar@google.com>
Mon, 29 Jun 2015 12:35:31 -0400
changeset 25691 5cda0ce05c42
parent 25690 98064baab877
child 25692 9f6e0e7ef828
wireproto: add config knob for http header length limit Well-behaved Mercurial clients will respect the httpheader capability by not sending http headers longer than the given limit in bytes. The limit is currently hard-coded at 1024 bytes, a safe value for any web server. Since parsing headers is a notable factor in web server performance, tuning header size can nontrivially improve performance for request-heavy operations (eg. obsolete marker negotiation). Exposing the maximum header length limit as a configuration setting is a simple way to enable such tuning.
mercurial/help/config.txt
mercurial/wireproto.py
--- a/mercurial/help/config.txt	Wed Jul 01 15:12:45 2015 -0500
+++ b/mercurial/help/config.txt	Mon Jun 29 12:35:31 2015 -0400
@@ -1291,6 +1291,10 @@
     checking that all new file revisions specified in manifests are
     present. Default is False.
 
+``maxhttpheaderlen``
+    Instruct HTTP clients not to send request headers longer than this
+    many bytes. Default is 1024.
+
 ``smtp``
 --------
 
--- a/mercurial/wireproto.py	Wed Jul 01 15:12:45 2015 -0500
+++ b/mercurial/wireproto.py	Mon Jun 29 12:35:31 2015 -0400
@@ -624,7 +624,8 @@
         capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo))
         caps.append('bundle2=' + urllib.quote(capsblob))
     caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority))
-    caps.append('httpheader=1024')
+    caps.append(
+        'httpheader=%d' % repo.ui.configint('server', 'maxhttpheaderlen', 1024))
     return caps
 
 # If you are writing an extension and consider wrapping this function. Wrap