[PATCH RFC] hgweb: add config option for maxhttpheadersize

Sune Foldager cryo at cyanite.org
Tue May 3 15:47:55 CDT 2011


Does this look good to you? Setting it to 0, the new arguments-in-headers
option can then be disabled, for debug or other purposes.

-Sune

# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1304455295 -7200
# Node ID 254b8682218b8257b3d25b23b6fb2b806ca5fd07
# Parent  fa2b596db18201408981e82ef7f9625a838e3ec9
hgweb: add config option for maxhttpheadersize

diff -r fa2b596db182 -r 254b8682218b mercurial/wireproto.py
--- a/mercurial/wireproto.py	Tue May 03 22:28:08 2011 +0200
+++ b/mercurial/wireproto.py	Tue May 03 22:41:35 2011 +0200
@@ -233,7 +233,9 @@
          else:
              caps.append('streamreqs=%s' % ','.join(requiredformats))
      caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority))
-    caps.append('httpheader=1024')
+    maxsize = repo.ui.configint('server', 'maxhttpheadersize', 1024,
+                                untrusted=True)
+    caps.append('httpheader=%d' % maxsize)
      return ' '.join(caps)
  
  def changegroup(repo, proto, roots):
diff -r fa2b596db182 -r 254b8682218b tests/test-wireproto.t
--- a/tests/test-wireproto.t	Tue May 03 22:28:08 2011 +0200
+++ b/tests/test-wireproto.t	Tue May 03 22:41:35 2011 +0200
@@ -54,14 +54,28 @@
    * - - [*] "GET /?cmd=debugwireargs HTTP/1.1" 200 - x-hgarg-1:four=onethousandcharactersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&one x-hgarg-2:=un&three=trois&two=deux (glob)
  
+HTTP with httpheader disabled by config:
+
+  $ HGRCPATH="`pwd`/repo/.hgrc"
+
+  $ hg serve -R repo -p $HGPORT1 -d --pid-file=hg2.pid -E error2.log -A access2.log --config server.maxhttpheadersize=0
+  $ cat hg2.pid >> $DAEMON_PIDS
+
+  $ hg debugwireargs http://localhost:$HGPORT1/ un deux trois quatre
+  un deux trois quatre None
+  $ cat error2.log
+  $ cat access2.log
+  * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
+  * - - [*] "GET /?cmd=debugwireargs&four=quatre&one=un&three=trois&two=deux HTTP/1.1" 200 - (glob)
+  * - - [*] "GET /?cmd=debugwireargs&four=quatre&one=un&three=trois&two=deux HTTP/1.1" 200 - (glob)
+
  HTTP without the httpheader capability:
  
-  $ HGRCPATH="`pwd`/repo/.hgrc"
    $ CAP=httpheader
    $ . "$TESTDIR/notcapable"
  
-  $ hg serve -R repo -p $HGPORT2 -d --pid-file=hg2.pid -E error2.log -A access2.log
-  $ cat hg2.pid >> $DAEMON_PIDS
+  $ hg serve -R repo -p $HGPORT2 -d --pid-file=hg3.pid -E error3.log -A access3.log
+  $ cat hg3.pid >> $DAEMON_PIDS
  
    $ hg debugwireargs http://localhost:$HGPORT2/ un deux trois quatre
    un deux trois quatre None
@@ -71,8 +85,8 @@
    eins zwei None None None
    $ hg debugwireargs http://localhost:$HGPORT2/ eins zwei --five fuenf
    eins zwei None None None
-  $ cat error2.log
-  $ cat access2.log
+  $ cat error3.log
+  $ cat access3.log
    * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
    * - - [*] "GET /?cmd=debugwireargs&four=quatre&one=un&three=trois&two=deux HTTP/1.1" 200 - (glob)
    * - - [*] "GET /?cmd=debugwireargs&four=quatre&one=un&three=trois&two=deux HTTP/1.1" 200 - (glob)


More information about the Mercurial-devel mailing list