Patchwork wireproto: add config knob for http header length limit

login
register
mail settings
Submitter adgar@google.com
Date June 29, 2015, 4:49 p.m.
Message ID <e3909b550d63b8f8c00a.1435596577@adgar.nyc.corp.google.com>
Download mbox | patch
Permalink /patch/9815/
State Superseded
Commit 5cda0ce05c42bab5882f64fe186884e3eca7a1f5
Headers show

Comments

adgar@google.com - June 29, 2015, 4:49 p.m.
# HG changeset patch
# User Mike Edgar <adgar@google.com>
# Date 1435595731 14400
#      Mon Jun 29 12:35:31 2015 -0400
# Node ID e3909b550d63b8f8c00ac322c24947f63dd1b468
# Parent  ff5172c830022b64cc5bd1bae36b2276e9dc6e5d
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.
Matt Mackall - June 29, 2015, 11:09 p.m.
On Mon, 2015-06-29 at 12:49 -0400, Mike Edgar wrote:
> # HG changeset patch
> # User Mike Edgar <adgar@google.com>
> # Date 1435595731 14400
> #      Mon Jun 29 12:35:31 2015 -0400
> # Node ID e3909b550d63b8f8c00ac322c24947f63dd1b468
> # Parent  ff5172c830022b64cc5bd1bae36b2276e9dc6e5d
> wireproto: add config knob for http header length limit

I think we want to document this one as I've occasionally wanted to tell
people to tweak it.

(Also, I have a big stack of patches here for making sure every config
option is either documented or flagged as intentionally hidden, so the
days of being lazy about this are coming to an end.)

Patch

diff -r ff5172c83002 -r e3909b550d63 mercurial/wireproto.py
--- a/mercurial/wireproto.py	Wed Jun 24 13:41:27 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