##// END OF EJS Templates
http: support sending hgargs via POST body instead of in GET or headers...
Augie Fackler -
r28530:fd2acc50 default
parent child Browse files
Show More
@@ -45,6 +45,11 b' class webproto(wireproto.abstractserverp'
45 return [data[k] for k in keys]
45 return [data[k] for k in keys]
46 def _args(self):
46 def _args(self):
47 args = self.req.form.copy()
47 args = self.req.form.copy()
48 postlen = int(self.req.env.get('HTTP_X_HGARGS_POST', 0))
49 if postlen:
50 args.update(cgi.parse_qs(
51 self.req.read(postlen), keep_blank_values=True))
52 return args
48 chunks = []
53 chunks = []
49 i = 1
54 i = 1
50 while True:
55 while True:
@@ -97,7 +97,22 b' class httppeer(wireproto.wirepeer):'
97 self.ui.debug("sending %s command\n" % cmd)
97 self.ui.debug("sending %s command\n" % cmd)
98 q = [('cmd', cmd)]
98 q = [('cmd', cmd)]
99 headersize = 0
99 headersize = 0
100 if True:
100 # Important: don't use self.capable() here or else you end up
101 # with infinite recursion when trying to look up capabilities
102 # for the first time.
103 postargsok = self.caps is not None and 'httppostargs' in self.caps
104 # TODO: support for httppostargs when data is a file-like
105 # object rather than a basestring
106 canmungedata = not data or isinstance(data, basestring)
107 if postargsok and canmungedata:
108 strargs = urllib.urlencode(sorted(args.items()))
109 if strargs:
110 if not data:
111 data = strargs
112 elif isinstance(data, basestring):
113 data = strargs + data
114 headers['X-HgArgs-Post'] = len(strargs)
115 else:
101 if len(args) > 0:
116 if len(args) > 0:
102 httpheader = self.capable('httpheader')
117 httpheader = self.capable('httpheader')
103 if httpheader:
118 if httpheader:
@@ -688,6 +688,8 b' def _capabilities(repo, proto):'
688 caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority))
688 caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority))
689 caps.append(
689 caps.append(
690 'httpheader=%d' % repo.ui.configint('server', 'maxhttpheaderlen', 1024))
690 'httpheader=%d' % repo.ui.configint('server', 'maxhttpheaderlen', 1024))
691 if repo.ui.configbool('experimental', 'httppostargs', False):
692 caps.append('httppostargs')
691 return caps
693 return caps
692
694
693 # If you are writing an extension and consider wrapping this function. Wrap
695 # If you are writing an extension and consider wrapping this function. Wrap
@@ -19,7 +19,9 b' Local:'
19
19
20 HTTP:
20 HTTP:
21
21
22 $ hg serve -R repo -p $HGPORT -d --pid-file=hg1.pid -E error.log -A access.log
22 $ hg serve -R repo -p $HGPORT -d --pid-file=hg1.pid \
23 > -E error.log -A access.log \
24 > --config experimental.httppostargs=yes
23 $ cat hg1.pid >> $DAEMON_PIDS
25 $ cat hg1.pid >> $DAEMON_PIDS
24
26
25 $ hg debugwireargs http://localhost:$HGPORT/ un deux trois quatre
27 $ hg debugwireargs http://localhost:$HGPORT/ un deux trois quatre
@@ -37,6 +39,61 b' HTTP:'
37 $ cat error.log
39 $ cat error.log
38 $ cat access.log
40 $ cat access.log
39 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
41 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
42 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:39 (glob)
43 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:39 (glob)
44 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
45 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:43 (glob)
46 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:43 (glob)
47 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
48 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:27 (glob)
49 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:27 (glob)
50 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
51 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:17 (glob)
52 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:17 (glob)
53 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
54 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:17 (glob)
55 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:17 (glob)
56 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
57 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:1033 (glob)
58 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:1033 (glob)
59
60 HTTP without args-in-POST:
61 $ hg serve -R repo -p $HGPORT1 -d --pid-file=hg1.pid -E error.log -A access.log
62 $ cat hg1.pid >> $DAEMON_PIDS
63
64 $ hg debugwireargs http://localhost:$HGPORT1/ un deux trois quatre
65 un deux trois quatre None
66 $ hg debugwireargs http://localhost:$HGPORT1/ \ un deux trois\ qu\ \ atre
67 un deux trois qu atre None
68 $ hg debugwireargs http://localhost:$HGPORT1/ eins zwei --four vier
69 eins zwei None vier None
70 $ hg debugwireargs http://localhost:$HGPORT1/ eins zwei
71 eins zwei None None None
72 $ hg debugwireargs http://localhost:$HGPORT1/ eins zwei --five fuenf
73 eins zwei None None None
74 $ hg debugwireargs http://localhost:$HGPORT1/ un deux trois onethousandcharactersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx None
76 $ cat error.log
77 $ cat access.log
78 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
79 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:39 (glob)
80 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:39 (glob)
81 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
82 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:43 (glob)
83 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:43 (glob)
84 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
85 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:27 (glob)
86 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:27 (glob)
87 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
88 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:17 (glob)
89 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:17 (glob)
90 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
91 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:17 (glob)
92 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:17 (glob)
93 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
94 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:1033 (glob)
95 * - - [*] "POST /?cmd=debugwireargs HTTP/1.1" 200 - x-hgargs-post:1033 (glob)
96 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
40 * - - [*] "GET /?cmd=debugwireargs HTTP/1.1" 200 - x-hgarg-1:four=quatre&one=un&three=trois&two=deux (glob)
97 * - - [*] "GET /?cmd=debugwireargs HTTP/1.1" 200 - x-hgarg-1:four=quatre&one=un&three=trois&two=deux (glob)
41 * - - [*] "GET /?cmd=debugwireargs HTTP/1.1" 200 - x-hgarg-1:four=quatre&one=un&three=trois&two=deux (glob)
98 * - - [*] "GET /?cmd=debugwireargs HTTP/1.1" 200 - x-hgarg-1:four=quatre&one=un&three=trois&two=deux (glob)
42 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
99 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
General Comments 0
You need to be logged in to leave comments. Login now