##// END OF EJS Templates
tests: add optional setsockopt() lines for Python 3...
Gregory Szorc -
r41447:4f0aca2b default
parent child Browse files
Show More
@@ -1,722 +1,743
1 #require no-chg
1 #require no-chg
2
2
3 $ . $TESTDIR/wireprotohelpers.sh
3 $ . $TESTDIR/wireprotohelpers.sh
4 $ enabledummycommands
4 $ enabledummycommands
5
5
6 $ hg init server
6 $ hg init server
7 $ cat > server/.hg/hgrc << EOF
7 $ cat > server/.hg/hgrc << EOF
8 > [experimental]
8 > [experimental]
9 > web.apiserver = true
9 > web.apiserver = true
10 > EOF
10 > EOF
11 $ hg -R server serve -p $HGPORT -d --pid-file hg.pid
11 $ hg -R server serve -p $HGPORT -d --pid-file hg.pid
12 $ cat hg.pid > $DAEMON_PIDS
12 $ cat hg.pid > $DAEMON_PIDS
13
13
14 HTTP v2 protocol not enabled by default
14 HTTP v2 protocol not enabled by default
15
15
16 $ sendhttpraw << EOF
16 $ sendhttpraw << EOF
17 > httprequest GET api/$HTTPV2
17 > httprequest GET api/$HTTPV2
18 > user-agent: test
18 > user-agent: test
19 > EOF
19 > EOF
20 using raw connection to peer
20 using raw connection to peer
21 s> setsockopt(6, 1, 1) -> None (py3 !)
21 s> GET /api/exp-http-v2-0003 HTTP/1.1\r\n
22 s> GET /api/exp-http-v2-0003 HTTP/1.1\r\n
22 s> Accept-Encoding: identity\r\n
23 s> Accept-Encoding: identity\r\n
23 s> user-agent: test\r\n
24 s> user-agent: test\r\n
24 s> host: $LOCALIP:$HGPORT\r\n (glob)
25 s> host: $LOCALIP:$HGPORT\r\n (glob)
25 s> \r\n
26 s> \r\n
26 s> makefile('rb', None)
27 s> makefile('rb', None)
27 s> HTTP/1.1 404 Not Found\r\n
28 s> HTTP/1.1 404 Not Found\r\n
28 s> Server: testing stub value\r\n
29 s> Server: testing stub value\r\n
29 s> Date: $HTTP_DATE$\r\n
30 s> Date: $HTTP_DATE$\r\n
30 s> Content-Type: text/plain\r\n
31 s> Content-Type: text/plain\r\n
31 s> Content-Length: 33\r\n
32 s> Content-Length: 33\r\n
32 s> \r\n
33 s> \r\n
33 s> API exp-http-v2-0003 not enabled\n
34 s> API exp-http-v2-0003 not enabled\n
34
35
35 Restart server with support for HTTP v2 API
36 Restart server with support for HTTP v2 API
36
37
37 $ killdaemons.py
38 $ killdaemons.py
38 $ enablehttpv2 server
39 $ enablehttpv2 server
39 $ hg -R server serve -p $HGPORT -d --pid-file hg.pid
40 $ hg -R server serve -p $HGPORT -d --pid-file hg.pid
40 $ cat hg.pid > $DAEMON_PIDS
41 $ cat hg.pid > $DAEMON_PIDS
41
42
42 Request to unknown command yields 404
43 Request to unknown command yields 404
43
44
44 $ sendhttpraw << EOF
45 $ sendhttpraw << EOF
45 > httprequest POST api/$HTTPV2/ro/badcommand
46 > httprequest POST api/$HTTPV2/ro/badcommand
46 > user-agent: test
47 > user-agent: test
47 > EOF
48 > EOF
48 using raw connection to peer
49 using raw connection to peer
50 s> setsockopt(6, 1, 1) -> None (py3 !)
49 s> POST /api/exp-http-v2-0003/ro/badcommand HTTP/1.1\r\n
51 s> POST /api/exp-http-v2-0003/ro/badcommand HTTP/1.1\r\n
50 s> Accept-Encoding: identity\r\n
52 s> Accept-Encoding: identity\r\n
51 s> user-agent: test\r\n
53 s> user-agent: test\r\n
52 s> host: $LOCALIP:$HGPORT\r\n (glob)
54 s> host: $LOCALIP:$HGPORT\r\n (glob)
53 s> \r\n
55 s> \r\n
54 s> makefile('rb', None)
56 s> makefile('rb', None)
55 s> HTTP/1.1 404 Not Found\r\n
57 s> HTTP/1.1 404 Not Found\r\n
56 s> Server: testing stub value\r\n
58 s> Server: testing stub value\r\n
57 s> Date: $HTTP_DATE$\r\n
59 s> Date: $HTTP_DATE$\r\n
58 s> Content-Type: text/plain\r\n
60 s> Content-Type: text/plain\r\n
59 s> Content-Length: 42\r\n
61 s> Content-Length: 42\r\n
60 s> \r\n
62 s> \r\n
61 s> unknown wire protocol command: badcommand\n
63 s> unknown wire protocol command: badcommand\n
62
64
63 GET to read-only command yields a 405
65 GET to read-only command yields a 405
64
66
65 $ sendhttpraw << EOF
67 $ sendhttpraw << EOF
66 > httprequest GET api/$HTTPV2/ro/customreadonly
68 > httprequest GET api/$HTTPV2/ro/customreadonly
67 > user-agent: test
69 > user-agent: test
68 > EOF
70 > EOF
69 using raw connection to peer
71 using raw connection to peer
72 s> setsockopt(6, 1, 1) -> None (py3 !)
70 s> GET /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
73 s> GET /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
71 s> Accept-Encoding: identity\r\n
74 s> Accept-Encoding: identity\r\n
72 s> user-agent: test\r\n
75 s> user-agent: test\r\n
73 s> host: $LOCALIP:$HGPORT\r\n (glob)
76 s> host: $LOCALIP:$HGPORT\r\n (glob)
74 s> \r\n
77 s> \r\n
75 s> makefile('rb', None)
78 s> makefile('rb', None)
76 s> HTTP/1.1 405 Method Not Allowed\r\n
79 s> HTTP/1.1 405 Method Not Allowed\r\n
77 s> Server: testing stub value\r\n
80 s> Server: testing stub value\r\n
78 s> Date: $HTTP_DATE$\r\n
81 s> Date: $HTTP_DATE$\r\n
79 s> Allow: POST\r\n
82 s> Allow: POST\r\n
80 s> Content-Length: 30\r\n
83 s> Content-Length: 30\r\n
81 s> \r\n
84 s> \r\n
82 s> commands require POST requests
85 s> commands require POST requests
83
86
84 Missing Accept header results in 406
87 Missing Accept header results in 406
85
88
86 $ sendhttpraw << EOF
89 $ sendhttpraw << EOF
87 > httprequest POST api/$HTTPV2/ro/customreadonly
90 > httprequest POST api/$HTTPV2/ro/customreadonly
88 > user-agent: test
91 > user-agent: test
89 > EOF
92 > EOF
90 using raw connection to peer
93 using raw connection to peer
94 s> setsockopt(6, 1, 1) -> None (py3 !)
91 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
95 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
92 s> Accept-Encoding: identity\r\n
96 s> Accept-Encoding: identity\r\n
93 s> user-agent: test\r\n
97 s> user-agent: test\r\n
94 s> host: $LOCALIP:$HGPORT\r\n (glob)
98 s> host: $LOCALIP:$HGPORT\r\n (glob)
95 s> \r\n
99 s> \r\n
96 s> makefile('rb', None)
100 s> makefile('rb', None)
97 s> HTTP/1.1 406 Not Acceptable\r\n
101 s> HTTP/1.1 406 Not Acceptable\r\n
98 s> Server: testing stub value\r\n
102 s> Server: testing stub value\r\n
99 s> Date: $HTTP_DATE$\r\n
103 s> Date: $HTTP_DATE$\r\n
100 s> Content-Type: text/plain\r\n
104 s> Content-Type: text/plain\r\n
101 s> Content-Length: 85\r\n
105 s> Content-Length: 85\r\n
102 s> \r\n
106 s> \r\n
103 s> client MUST specify Accept header with value: application/mercurial-exp-framing-0006\n
107 s> client MUST specify Accept header with value: application/mercurial-exp-framing-0006\n
104
108
105 Bad Accept header results in 406
109 Bad Accept header results in 406
106
110
107 $ sendhttpraw << EOF
111 $ sendhttpraw << EOF
108 > httprequest POST api/$HTTPV2/ro/customreadonly
112 > httprequest POST api/$HTTPV2/ro/customreadonly
109 > accept: invalid
113 > accept: invalid
110 > user-agent: test
114 > user-agent: test
111 > EOF
115 > EOF
112 using raw connection to peer
116 using raw connection to peer
117 s> setsockopt(6, 1, 1) -> None (py3 !)
113 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
118 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
114 s> Accept-Encoding: identity\r\n
119 s> Accept-Encoding: identity\r\n
115 s> accept: invalid\r\n
120 s> accept: invalid\r\n
116 s> user-agent: test\r\n
121 s> user-agent: test\r\n
117 s> host: $LOCALIP:$HGPORT\r\n (glob)
122 s> host: $LOCALIP:$HGPORT\r\n (glob)
118 s> \r\n
123 s> \r\n
119 s> makefile('rb', None)
124 s> makefile('rb', None)
120 s> HTTP/1.1 406 Not Acceptable\r\n
125 s> HTTP/1.1 406 Not Acceptable\r\n
121 s> Server: testing stub value\r\n
126 s> Server: testing stub value\r\n
122 s> Date: $HTTP_DATE$\r\n
127 s> Date: $HTTP_DATE$\r\n
123 s> Content-Type: text/plain\r\n
128 s> Content-Type: text/plain\r\n
124 s> Content-Length: 85\r\n
129 s> Content-Length: 85\r\n
125 s> \r\n
130 s> \r\n
126 s> client MUST specify Accept header with value: application/mercurial-exp-framing-0006\n
131 s> client MUST specify Accept header with value: application/mercurial-exp-framing-0006\n
127
132
128 Bad Content-Type header results in 415
133 Bad Content-Type header results in 415
129
134
130 $ sendhttpraw << EOF
135 $ sendhttpraw << EOF
131 > httprequest POST api/$HTTPV2/ro/customreadonly
136 > httprequest POST api/$HTTPV2/ro/customreadonly
132 > accept: $MEDIATYPE
137 > accept: $MEDIATYPE
133 > user-agent: test
138 > user-agent: test
134 > content-type: badmedia
139 > content-type: badmedia
135 > EOF
140 > EOF
136 using raw connection to peer
141 using raw connection to peer
142 s> setsockopt(6, 1, 1) -> None (py3 !)
137 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
143 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
138 s> Accept-Encoding: identity\r\n
144 s> Accept-Encoding: identity\r\n
139 s> accept: application/mercurial-exp-framing-0006\r\n
145 s> accept: application/mercurial-exp-framing-0006\r\n
140 s> content-type: badmedia\r\n
146 s> content-type: badmedia\r\n
141 s> user-agent: test\r\n
147 s> user-agent: test\r\n
142 s> host: $LOCALIP:$HGPORT\r\n (glob)
148 s> host: $LOCALIP:$HGPORT\r\n (glob)
143 s> \r\n
149 s> \r\n
144 s> makefile('rb', None)
150 s> makefile('rb', None)
145 s> HTTP/1.1 415 Unsupported Media Type\r\n
151 s> HTTP/1.1 415 Unsupported Media Type\r\n
146 s> Server: testing stub value\r\n
152 s> Server: testing stub value\r\n
147 s> Date: $HTTP_DATE$\r\n
153 s> Date: $HTTP_DATE$\r\n
148 s> Content-Type: text/plain\r\n
154 s> Content-Type: text/plain\r\n
149 s> Content-Length: 88\r\n
155 s> Content-Length: 88\r\n
150 s> \r\n
156 s> \r\n
151 s> client MUST send Content-Type header with value: application/mercurial-exp-framing-0006\n
157 s> client MUST send Content-Type header with value: application/mercurial-exp-framing-0006\n
152
158
153 Request to read-only command works out of the box
159 Request to read-only command works out of the box
154
160
155 $ sendhttpraw << EOF
161 $ sendhttpraw << EOF
156 > httprequest POST api/$HTTPV2/ro/customreadonly
162 > httprequest POST api/$HTTPV2/ro/customreadonly
157 > accept: $MEDIATYPE
163 > accept: $MEDIATYPE
158 > content-type: $MEDIATYPE
164 > content-type: $MEDIATYPE
159 > user-agent: test
165 > user-agent: test
160 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'}
166 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'}
161 > EOF
167 > EOF
162 using raw connection to peer
168 using raw connection to peer
169 s> setsockopt(6, 1, 1) -> None (py3 !)
163 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
170 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
164 s> Accept-Encoding: identity\r\n
171 s> Accept-Encoding: identity\r\n
165 s> *\r\n (glob)
172 s> *\r\n (glob)
166 s> content-type: application/mercurial-exp-framing-0006\r\n
173 s> content-type: application/mercurial-exp-framing-0006\r\n
167 s> user-agent: test\r\n
174 s> user-agent: test\r\n
168 s> content-length: 29\r\n
175 s> content-length: 29\r\n
169 s> host: $LOCALIP:$HGPORT\r\n (glob)
176 s> host: $LOCALIP:$HGPORT\r\n (glob)
170 s> \r\n
177 s> \r\n
171 s> \x15\x00\x00\x01\x00\x01\x01\x11\xa1DnameNcustomreadonly
178 s> \x15\x00\x00\x01\x00\x01\x01\x11\xa1DnameNcustomreadonly
172 s> makefile('rb', None)
179 s> makefile('rb', None)
173 s> HTTP/1.1 200 OK\r\n
180 s> HTTP/1.1 200 OK\r\n
174 s> Server: testing stub value\r\n
181 s> Server: testing stub value\r\n
175 s> Date: $HTTP_DATE$\r\n
182 s> Date: $HTTP_DATE$\r\n
176 s> Content-Type: application/mercurial-exp-framing-0006\r\n
183 s> Content-Type: application/mercurial-exp-framing-0006\r\n
177 s> Transfer-Encoding: chunked\r\n
184 s> Transfer-Encoding: chunked\r\n
178 s> \r\n
185 s> \r\n
179 s> 11\r\n
186 s> 11\r\n
180 s> \t\x00\x00\x01\x00\x02\x01\x92Hidentity
187 s> \t\x00\x00\x01\x00\x02\x01\x92Hidentity
181 s> \r\n
188 s> \r\n
182 s> 13\r\n
189 s> 13\r\n
183 s> \x0b\x00\x00\x01\x00\x02\x041\xa1FstatusBok
190 s> \x0b\x00\x00\x01\x00\x02\x041\xa1FstatusBok
184 s> \r\n
191 s> \r\n
185 s> 27\r\n
192 s> 27\r\n
186 s> \x1f\x00\x00\x01\x00\x02\x041X\x1dcustomreadonly bytes response
193 s> \x1f\x00\x00\x01\x00\x02\x041X\x1dcustomreadonly bytes response
187 s> \r\n
194 s> \r\n
188 s> 8\r\n
195 s> 8\r\n
189 s> \x00\x00\x00\x01\x00\x02\x002
196 s> \x00\x00\x00\x01\x00\x02\x002
190 s> \r\n
197 s> \r\n
191 s> 0\r\n
198 s> 0\r\n
192 s> \r\n
199 s> \r\n
193
200
194 $ sendhttpv2peerverbose << EOF
201 $ sendhttpv2peerverbose << EOF
195 > command customreadonly
202 > command customreadonly
196 > EOF
203 > EOF
197 creating http peer for wire protocol version 2
204 creating http peer for wire protocol version 2
198 sending customreadonly command
205 sending customreadonly command
206 s> setsockopt(6, 1, 1) -> None (py3 !)
199 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
207 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
200 s> Accept-Encoding: identity\r\n
208 s> Accept-Encoding: identity\r\n
201 s> accept: application/mercurial-exp-framing-0006\r\n
209 s> accept: application/mercurial-exp-framing-0006\r\n
202 s> content-type: application/mercurial-exp-framing-0006\r\n
210 s> content-type: application/mercurial-exp-framing-0006\r\n
203 s> content-length: 65\r\n
211 s> content-length: 65\r\n
204 s> host: $LOCALIP:$HGPORT\r\n (glob)
212 s> host: $LOCALIP:$HGPORT\r\n (glob)
205 s> user-agent: Mercurial debugwireproto\r\n
213 s> user-agent: Mercurial debugwireproto\r\n
206 s> \r\n
214 s> \r\n
207 s> \x1c\x00\x00\x01\x00\x01\x01\x82\xa1Pcontentencodings\x81Hidentity\x15\x00\x00\x01\x00\x01\x00\x11\xa1DnameNcustomreadonly
215 s> \x1c\x00\x00\x01\x00\x01\x01\x82\xa1Pcontentencodings\x81Hidentity\x15\x00\x00\x01\x00\x01\x00\x11\xa1DnameNcustomreadonly
208 s> makefile('rb', None)
216 s> makefile('rb', None)
209 s> HTTP/1.1 200 OK\r\n
217 s> HTTP/1.1 200 OK\r\n
210 s> Server: testing stub value\r\n
218 s> Server: testing stub value\r\n
211 s> Date: $HTTP_DATE$\r\n
219 s> Date: $HTTP_DATE$\r\n
212 s> Content-Type: application/mercurial-exp-framing-0006\r\n
220 s> Content-Type: application/mercurial-exp-framing-0006\r\n
213 s> Transfer-Encoding: chunked\r\n
221 s> Transfer-Encoding: chunked\r\n
214 s> \r\n
222 s> \r\n
215 s> 11\r\n
223 s> 11\r\n
216 s> \t\x00\x00\x01\x00\x02\x01\x92
224 s> \t\x00\x00\x01\x00\x02\x01\x92
217 s> Hidentity
225 s> Hidentity
218 s> \r\n
226 s> \r\n
219 s> 13\r\n
227 s> 13\r\n
220 s> \x0b\x00\x00\x01\x00\x02\x041
228 s> \x0b\x00\x00\x01\x00\x02\x041
221 s> \xa1FstatusBok
229 s> \xa1FstatusBok
222 s> \r\n
230 s> \r\n
223 s> 27\r\n
231 s> 27\r\n
224 s> \x1f\x00\x00\x01\x00\x02\x041
232 s> \x1f\x00\x00\x01\x00\x02\x041
225 s> X\x1dcustomreadonly bytes response
233 s> X\x1dcustomreadonly bytes response
226 s> \r\n
234 s> \r\n
227 s> 8\r\n
235 s> 8\r\n
228 s> \x00\x00\x00\x01\x00\x02\x002
236 s> \x00\x00\x00\x01\x00\x02\x002
229 s> \r\n
237 s> \r\n
230 s> 0\r\n
238 s> 0\r\n
231 s> \r\n
239 s> \r\n
232 response: gen[
240 response: gen[
233 b'customreadonly bytes response'
241 b'customreadonly bytes response'
234 ]
242 ]
235 (sent 2 HTTP requests and * bytes; received * bytes in responses) (glob)
243 (sent 2 HTTP requests and * bytes; received * bytes in responses) (glob)
236
244
237 Request to read-write command fails because server is read-only by default
245 Request to read-write command fails because server is read-only by default
238
246
239 GET to read-write request yields 405
247 GET to read-write request yields 405
240
248
241 $ sendhttpraw << EOF
249 $ sendhttpraw << EOF
242 > httprequest GET api/$HTTPV2/rw/customreadonly
250 > httprequest GET api/$HTTPV2/rw/customreadonly
243 > user-agent: test
251 > user-agent: test
244 > EOF
252 > EOF
245 using raw connection to peer
253 using raw connection to peer
254 s> setsockopt(6, 1, 1) -> None (py3 !)
246 s> GET /api/exp-http-v2-0003/rw/customreadonly HTTP/1.1\r\n
255 s> GET /api/exp-http-v2-0003/rw/customreadonly HTTP/1.1\r\n
247 s> Accept-Encoding: identity\r\n
256 s> Accept-Encoding: identity\r\n
248 s> user-agent: test\r\n
257 s> user-agent: test\r\n
249 s> host: $LOCALIP:$HGPORT\r\n (glob)
258 s> host: $LOCALIP:$HGPORT\r\n (glob)
250 s> \r\n
259 s> \r\n
251 s> makefile('rb', None)
260 s> makefile('rb', None)
252 s> HTTP/1.1 405 Method Not Allowed\r\n
261 s> HTTP/1.1 405 Method Not Allowed\r\n
253 s> Server: testing stub value\r\n
262 s> Server: testing stub value\r\n
254 s> Date: $HTTP_DATE$\r\n
263 s> Date: $HTTP_DATE$\r\n
255 s> Allow: POST\r\n
264 s> Allow: POST\r\n
256 s> Content-Length: 30\r\n
265 s> Content-Length: 30\r\n
257 s> \r\n
266 s> \r\n
258 s> commands require POST requests
267 s> commands require POST requests
259
268
260 Even for unknown commands
269 Even for unknown commands
261
270
262 $ sendhttpraw << EOF
271 $ sendhttpraw << EOF
263 > httprequest GET api/$HTTPV2/rw/badcommand
272 > httprequest GET api/$HTTPV2/rw/badcommand
264 > user-agent: test
273 > user-agent: test
265 > EOF
274 > EOF
266 using raw connection to peer
275 using raw connection to peer
276 s> setsockopt(6, 1, 1) -> None (py3 !)
267 s> GET /api/exp-http-v2-0003/rw/badcommand HTTP/1.1\r\n
277 s> GET /api/exp-http-v2-0003/rw/badcommand HTTP/1.1\r\n
268 s> Accept-Encoding: identity\r\n
278 s> Accept-Encoding: identity\r\n
269 s> user-agent: test\r\n
279 s> user-agent: test\r\n
270 s> host: $LOCALIP:$HGPORT\r\n (glob)
280 s> host: $LOCALIP:$HGPORT\r\n (glob)
271 s> \r\n
281 s> \r\n
272 s> makefile('rb', None)
282 s> makefile('rb', None)
273 s> HTTP/1.1 405 Method Not Allowed\r\n
283 s> HTTP/1.1 405 Method Not Allowed\r\n
274 s> Server: testing stub value\r\n
284 s> Server: testing stub value\r\n
275 s> Date: $HTTP_DATE$\r\n
285 s> Date: $HTTP_DATE$\r\n
276 s> Allow: POST\r\n
286 s> Allow: POST\r\n
277 s> Content-Length: 30\r\n
287 s> Content-Length: 30\r\n
278 s> \r\n
288 s> \r\n
279 s> commands require POST requests
289 s> commands require POST requests
280
290
281 SSL required by default
291 SSL required by default
282
292
283 $ sendhttpraw << EOF
293 $ sendhttpraw << EOF
284 > httprequest POST api/$HTTPV2/rw/customreadonly
294 > httprequest POST api/$HTTPV2/rw/customreadonly
285 > user-agent: test
295 > user-agent: test
286 > EOF
296 > EOF
287 using raw connection to peer
297 using raw connection to peer
298 s> setsockopt(6, 1, 1) -> None (py3 !)
288 s> POST /api/exp-http-v2-0003/rw/customreadonly HTTP/1.1\r\n
299 s> POST /api/exp-http-v2-0003/rw/customreadonly HTTP/1.1\r\n
289 s> Accept-Encoding: identity\r\n
300 s> Accept-Encoding: identity\r\n
290 s> user-agent: test\r\n
301 s> user-agent: test\r\n
291 s> host: $LOCALIP:$HGPORT\r\n (glob)
302 s> host: $LOCALIP:$HGPORT\r\n (glob)
292 s> \r\n
303 s> \r\n
293 s> makefile('rb', None)
304 s> makefile('rb', None)
294 s> HTTP/1.1 403 ssl required\r\n
305 s> HTTP/1.1 403 ssl required\r\n
295 s> Server: testing stub value\r\n
306 s> Server: testing stub value\r\n
296 s> Date: $HTTP_DATE$\r\n
307 s> Date: $HTTP_DATE$\r\n
297 s> Content-Length: 17\r\n
308 s> Content-Length: 17\r\n
298 s> \r\n
309 s> \r\n
299 s> permission denied
310 s> permission denied
300
311
301 Restart server to allow non-ssl read-write operations
312 Restart server to allow non-ssl read-write operations
302
313
303 $ killdaemons.py
314 $ killdaemons.py
304 $ cat > server/.hg/hgrc << EOF
315 $ cat > server/.hg/hgrc << EOF
305 > [experimental]
316 > [experimental]
306 > web.apiserver = true
317 > web.apiserver = true
307 > web.api.http-v2 = true
318 > web.api.http-v2 = true
308 > [web]
319 > [web]
309 > push_ssl = false
320 > push_ssl = false
310 > allow-push = *
321 > allow-push = *
311 > EOF
322 > EOF
312
323
313 $ hg -R server serve -p $HGPORT -d --pid-file hg.pid -E error.log
324 $ hg -R server serve -p $HGPORT -d --pid-file hg.pid -E error.log
314 $ cat hg.pid > $DAEMON_PIDS
325 $ cat hg.pid > $DAEMON_PIDS
315
326
316 Authorized request for valid read-write command works
327 Authorized request for valid read-write command works
317
328
318 $ sendhttpraw << EOF
329 $ sendhttpraw << EOF
319 > httprequest POST api/$HTTPV2/rw/customreadonly
330 > httprequest POST api/$HTTPV2/rw/customreadonly
320 > user-agent: test
331 > user-agent: test
321 > accept: $MEDIATYPE
332 > accept: $MEDIATYPE
322 > content-type: $MEDIATYPE
333 > content-type: $MEDIATYPE
323 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'}
334 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'}
324 > EOF
335 > EOF
325 using raw connection to peer
336 using raw connection to peer
337 s> setsockopt(6, 1, 1) -> None (py3 !)
326 s> POST /api/exp-http-v2-0003/rw/customreadonly HTTP/1.1\r\n
338 s> POST /api/exp-http-v2-0003/rw/customreadonly HTTP/1.1\r\n
327 s> Accept-Encoding: identity\r\n
339 s> Accept-Encoding: identity\r\n
328 s> accept: application/mercurial-exp-framing-0006\r\n
340 s> accept: application/mercurial-exp-framing-0006\r\n
329 s> content-type: application/mercurial-exp-framing-0006\r\n
341 s> content-type: application/mercurial-exp-framing-0006\r\n
330 s> user-agent: test\r\n
342 s> user-agent: test\r\n
331 s> content-length: 29\r\n
343 s> content-length: 29\r\n
332 s> host: $LOCALIP:$HGPORT\r\n (glob)
344 s> host: $LOCALIP:$HGPORT\r\n (glob)
333 s> \r\n
345 s> \r\n
334 s> \x15\x00\x00\x01\x00\x01\x01\x11\xa1DnameNcustomreadonly
346 s> \x15\x00\x00\x01\x00\x01\x01\x11\xa1DnameNcustomreadonly
335 s> makefile('rb', None)
347 s> makefile('rb', None)
336 s> HTTP/1.1 200 OK\r\n
348 s> HTTP/1.1 200 OK\r\n
337 s> Server: testing stub value\r\n
349 s> Server: testing stub value\r\n
338 s> Date: $HTTP_DATE$\r\n
350 s> Date: $HTTP_DATE$\r\n
339 s> Content-Type: application/mercurial-exp-framing-0006\r\n
351 s> Content-Type: application/mercurial-exp-framing-0006\r\n
340 s> Transfer-Encoding: chunked\r\n
352 s> Transfer-Encoding: chunked\r\n
341 s> \r\n
353 s> \r\n
342 s> 11\r\n
354 s> 11\r\n
343 s> \t\x00\x00\x01\x00\x02\x01\x92Hidentity
355 s> \t\x00\x00\x01\x00\x02\x01\x92Hidentity
344 s> \r\n
356 s> \r\n
345 s> 13\r\n
357 s> 13\r\n
346 s> \x0b\x00\x00\x01\x00\x02\x041\xa1FstatusBok
358 s> \x0b\x00\x00\x01\x00\x02\x041\xa1FstatusBok
347 s> \r\n
359 s> \r\n
348 s> 27\r\n
360 s> 27\r\n
349 s> \x1f\x00\x00\x01\x00\x02\x041X\x1dcustomreadonly bytes response
361 s> \x1f\x00\x00\x01\x00\x02\x041X\x1dcustomreadonly bytes response
350 s> \r\n
362 s> \r\n
351 s> 8\r\n
363 s> 8\r\n
352 s> \x00\x00\x00\x01\x00\x02\x002
364 s> \x00\x00\x00\x01\x00\x02\x002
353 s> \r\n
365 s> \r\n
354 s> 0\r\n
366 s> 0\r\n
355 s> \r\n
367 s> \r\n
356
368
357 Authorized request for unknown command is rejected
369 Authorized request for unknown command is rejected
358
370
359 $ sendhttpraw << EOF
371 $ sendhttpraw << EOF
360 > httprequest POST api/$HTTPV2/rw/badcommand
372 > httprequest POST api/$HTTPV2/rw/badcommand
361 > user-agent: test
373 > user-agent: test
362 > accept: $MEDIATYPE
374 > accept: $MEDIATYPE
363 > EOF
375 > EOF
364 using raw connection to peer
376 using raw connection to peer
377 s> setsockopt(6, 1, 1) -> None (py3 !)
365 s> POST /api/exp-http-v2-0003/rw/badcommand HTTP/1.1\r\n
378 s> POST /api/exp-http-v2-0003/rw/badcommand HTTP/1.1\r\n
366 s> Accept-Encoding: identity\r\n
379 s> Accept-Encoding: identity\r\n
367 s> accept: application/mercurial-exp-framing-0006\r\n
380 s> accept: application/mercurial-exp-framing-0006\r\n
368 s> user-agent: test\r\n
381 s> user-agent: test\r\n
369 s> host: $LOCALIP:$HGPORT\r\n (glob)
382 s> host: $LOCALIP:$HGPORT\r\n (glob)
370 s> \r\n
383 s> \r\n
371 s> makefile('rb', None)
384 s> makefile('rb', None)
372 s> HTTP/1.1 404 Not Found\r\n
385 s> HTTP/1.1 404 Not Found\r\n
373 s> Server: testing stub value\r\n
386 s> Server: testing stub value\r\n
374 s> Date: $HTTP_DATE$\r\n
387 s> Date: $HTTP_DATE$\r\n
375 s> Content-Type: text/plain\r\n
388 s> Content-Type: text/plain\r\n
376 s> Content-Length: 42\r\n
389 s> Content-Length: 42\r\n
377 s> \r\n
390 s> \r\n
378 s> unknown wire protocol command: badcommand\n
391 s> unknown wire protocol command: badcommand\n
379
392
380 debugreflect isn't enabled by default
393 debugreflect isn't enabled by default
381
394
382 $ sendhttpraw << EOF
395 $ sendhttpraw << EOF
383 > httprequest POST api/$HTTPV2/ro/debugreflect
396 > httprequest POST api/$HTTPV2/ro/debugreflect
384 > user-agent: test
397 > user-agent: test
385 > EOF
398 > EOF
386 using raw connection to peer
399 using raw connection to peer
400 s> setsockopt(6, 1, 1) -> None (py3 !)
387 s> POST /api/exp-http-v2-0003/ro/debugreflect HTTP/1.1\r\n
401 s> POST /api/exp-http-v2-0003/ro/debugreflect HTTP/1.1\r\n
388 s> Accept-Encoding: identity\r\n
402 s> Accept-Encoding: identity\r\n
389 s> user-agent: test\r\n
403 s> user-agent: test\r\n
390 s> host: $LOCALIP:$HGPORT\r\n (glob)
404 s> host: $LOCALIP:$HGPORT\r\n (glob)
391 s> \r\n
405 s> \r\n
392 s> makefile('rb', None)
406 s> makefile('rb', None)
393 s> HTTP/1.1 404 Not Found\r\n
407 s> HTTP/1.1 404 Not Found\r\n
394 s> Server: testing stub value\r\n
408 s> Server: testing stub value\r\n
395 s> Date: $HTTP_DATE$\r\n
409 s> Date: $HTTP_DATE$\r\n
396 s> Content-Type: text/plain\r\n
410 s> Content-Type: text/plain\r\n
397 s> Content-Length: 34\r\n
411 s> Content-Length: 34\r\n
398 s> \r\n
412 s> \r\n
399 s> debugreflect service not available
413 s> debugreflect service not available
400
414
401 Restart server to get debugreflect endpoint
415 Restart server to get debugreflect endpoint
402
416
403 $ killdaemons.py
417 $ killdaemons.py
404 $ cat > server/.hg/hgrc << EOF
418 $ cat > server/.hg/hgrc << EOF
405 > [experimental]
419 > [experimental]
406 > web.apiserver = true
420 > web.apiserver = true
407 > web.api.debugreflect = true
421 > web.api.debugreflect = true
408 > web.api.http-v2 = true
422 > web.api.http-v2 = true
409 > [web]
423 > [web]
410 > push_ssl = false
424 > push_ssl = false
411 > allow-push = *
425 > allow-push = *
412 > EOF
426 > EOF
413
427
414 $ hg -R server serve -p $HGPORT -d --pid-file hg.pid -E error.log
428 $ hg -R server serve -p $HGPORT -d --pid-file hg.pid -E error.log
415 $ cat hg.pid > $DAEMON_PIDS
429 $ cat hg.pid > $DAEMON_PIDS
416
430
417 Command frames can be reflected via debugreflect
431 Command frames can be reflected via debugreflect
418
432
419 $ sendhttpraw << EOF
433 $ sendhttpraw << EOF
420 > httprequest POST api/$HTTPV2/ro/debugreflect
434 > httprequest POST api/$HTTPV2/ro/debugreflect
421 > accept: $MEDIATYPE
435 > accept: $MEDIATYPE
422 > content-type: $MEDIATYPE
436 > content-type: $MEDIATYPE
423 > user-agent: test
437 > user-agent: test
424 > frame 1 1 stream-begin command-request new cbor:{b'name': b'command1', b'args': {b'foo': b'val1', b'bar1': b'val'}}
438 > frame 1 1 stream-begin command-request new cbor:{b'name': b'command1', b'args': {b'foo': b'val1', b'bar1': b'val'}}
425 > EOF
439 > EOF
426 using raw connection to peer
440 using raw connection to peer
441 s> setsockopt(6, 1, 1) -> None (py3 !)
427 s> POST /api/exp-http-v2-0003/ro/debugreflect HTTP/1.1\r\n
442 s> POST /api/exp-http-v2-0003/ro/debugreflect HTTP/1.1\r\n
428 s> Accept-Encoding: identity\r\n
443 s> Accept-Encoding: identity\r\n
429 s> accept: application/mercurial-exp-framing-0006\r\n
444 s> accept: application/mercurial-exp-framing-0006\r\n
430 s> content-type: application/mercurial-exp-framing-0006\r\n
445 s> content-type: application/mercurial-exp-framing-0006\r\n
431 s> user-agent: test\r\n
446 s> user-agent: test\r\n
432 s> content-length: 47\r\n
447 s> content-length: 47\r\n
433 s> host: $LOCALIP:$HGPORT\r\n (glob)
448 s> host: $LOCALIP:$HGPORT\r\n (glob)
434 s> \r\n
449 s> \r\n
435 s> \'\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa2Dbar1CvalCfooDval1DnameHcommand1
450 s> \'\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa2Dbar1CvalCfooDval1DnameHcommand1
436 s> makefile('rb', None)
451 s> makefile('rb', None)
437 s> HTTP/1.1 200 OK\r\n
452 s> HTTP/1.1 200 OK\r\n
438 s> Server: testing stub value\r\n
453 s> Server: testing stub value\r\n
439 s> Date: $HTTP_DATE$\r\n
454 s> Date: $HTTP_DATE$\r\n
440 s> Content-Type: text/plain\r\n
455 s> Content-Type: text/plain\r\n
441 s> Content-Length: 223\r\n
456 s> Content-Length: 223\r\n
442 s> \r\n
457 s> \r\n
443 s> received: 1 1 1 \xa2Dargs\xa2Dbar1CvalCfooDval1DnameHcommand1\n
458 s> received: 1 1 1 \xa2Dargs\xa2Dbar1CvalCfooDval1DnameHcommand1\n
444 s> ["runcommand", {"args": {"bar1": "val", "foo": "val1"}, "command": "command1", "data": null, "redirect": null, "requestid": 1}]\n
459 s> ["runcommand", {"args": {"bar1": "val", "foo": "val1"}, "command": "command1", "data": null, "redirect": null, "requestid": 1}]\n
445 s> received: <no frame>\n
460 s> received: <no frame>\n
446 s> {"action": "noop"}
461 s> {"action": "noop"}
447
462
448 Multiple requests to regular command URL are not allowed
463 Multiple requests to regular command URL are not allowed
449
464
450 $ sendhttpraw << EOF
465 $ sendhttpraw << EOF
451 > httprequest POST api/$HTTPV2/ro/customreadonly
466 > httprequest POST api/$HTTPV2/ro/customreadonly
452 > accept: $MEDIATYPE
467 > accept: $MEDIATYPE
453 > content-type: $MEDIATYPE
468 > content-type: $MEDIATYPE
454 > user-agent: test
469 > user-agent: test
455 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'}
470 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'}
456 > EOF
471 > EOF
457 using raw connection to peer
472 using raw connection to peer
473 s> setsockopt(6, 1, 1) -> None (py3 !)
458 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
474 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
459 s> Accept-Encoding: identity\r\n
475 s> Accept-Encoding: identity\r\n
460 s> accept: application/mercurial-exp-framing-0006\r\n
476 s> accept: application/mercurial-exp-framing-0006\r\n
461 s> content-type: application/mercurial-exp-framing-0006\r\n
477 s> content-type: application/mercurial-exp-framing-0006\r\n
462 s> user-agent: test\r\n
478 s> user-agent: test\r\n
463 s> content-length: 29\r\n
479 s> content-length: 29\r\n
464 s> host: $LOCALIP:$HGPORT\r\n (glob)
480 s> host: $LOCALIP:$HGPORT\r\n (glob)
465 s> \r\n
481 s> \r\n
466 s> \x15\x00\x00\x01\x00\x01\x01\x11\xa1DnameNcustomreadonly
482 s> \x15\x00\x00\x01\x00\x01\x01\x11\xa1DnameNcustomreadonly
467 s> makefile('rb', None)
483 s> makefile('rb', None)
468 s> HTTP/1.1 200 OK\r\n
484 s> HTTP/1.1 200 OK\r\n
469 s> Server: testing stub value\r\n
485 s> Server: testing stub value\r\n
470 s> Date: $HTTP_DATE$\r\n
486 s> Date: $HTTP_DATE$\r\n
471 s> Content-Type: application/mercurial-exp-framing-0006\r\n
487 s> Content-Type: application/mercurial-exp-framing-0006\r\n
472 s> Transfer-Encoding: chunked\r\n
488 s> Transfer-Encoding: chunked\r\n
473 s> \r\n
489 s> \r\n
474 s> 11\r\n
490 s> 11\r\n
475 s> \t\x00\x00\x01\x00\x02\x01\x92Hidentity
491 s> \t\x00\x00\x01\x00\x02\x01\x92Hidentity
476 s> \r\n
492 s> \r\n
477 s> 13\r\n
493 s> 13\r\n
478 s> \x0b\x00\x00\x01\x00\x02\x041\xa1FstatusBok
494 s> \x0b\x00\x00\x01\x00\x02\x041\xa1FstatusBok
479 s> \r\n
495 s> \r\n
480 s> 27\r\n
496 s> 27\r\n
481 s> \x1f\x00\x00\x01\x00\x02\x041X\x1dcustomreadonly bytes response
497 s> \x1f\x00\x00\x01\x00\x02\x041X\x1dcustomreadonly bytes response
482 s> \r\n
498 s> \r\n
483 s> 8\r\n
499 s> 8\r\n
484 s> \x00\x00\x00\x01\x00\x02\x002
500 s> \x00\x00\x00\x01\x00\x02\x002
485 s> \r\n
501 s> \r\n
486 s> 0\r\n
502 s> 0\r\n
487 s> \r\n
503 s> \r\n
488
504
489 Multiple requests to "multirequest" URL are allowed
505 Multiple requests to "multirequest" URL are allowed
490
506
491 $ sendhttpraw << EOF
507 $ sendhttpraw << EOF
492 > httprequest POST api/$HTTPV2/ro/multirequest
508 > httprequest POST api/$HTTPV2/ro/multirequest
493 > accept: $MEDIATYPE
509 > accept: $MEDIATYPE
494 > content-type: $MEDIATYPE
510 > content-type: $MEDIATYPE
495 > user-agent: test
511 > user-agent: test
496 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'}
512 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'}
497 > frame 3 1 0 command-request new cbor:{b'name': b'customreadonly'}
513 > frame 3 1 0 command-request new cbor:{b'name': b'customreadonly'}
498 > EOF
514 > EOF
499 using raw connection to peer
515 using raw connection to peer
516 s> setsockopt(6, 1, 1) -> None (py3 !)
500 s> POST /api/exp-http-v2-0003/ro/multirequest HTTP/1.1\r\n
517 s> POST /api/exp-http-v2-0003/ro/multirequest HTTP/1.1\r\n
501 s> Accept-Encoding: identity\r\n
518 s> Accept-Encoding: identity\r\n
502 s> *\r\n (glob)
519 s> *\r\n (glob)
503 s> *\r\n (glob)
520 s> *\r\n (glob)
504 s> user-agent: test\r\n
521 s> user-agent: test\r\n
505 s> content-length: 58\r\n
522 s> content-length: 58\r\n
506 s> host: $LOCALIP:$HGPORT\r\n (glob)
523 s> host: $LOCALIP:$HGPORT\r\n (glob)
507 s> \r\n
524 s> \r\n
508 s> \x15\x00\x00\x01\x00\x01\x01\x11\xa1DnameNcustomreadonly\x15\x00\x00\x03\x00\x01\x00\x11\xa1DnameNcustomreadonly
525 s> \x15\x00\x00\x01\x00\x01\x01\x11\xa1DnameNcustomreadonly\x15\x00\x00\x03\x00\x01\x00\x11\xa1DnameNcustomreadonly
509 s> makefile('rb', None)
526 s> makefile('rb', None)
510 s> HTTP/1.1 200 OK\r\n
527 s> HTTP/1.1 200 OK\r\n
511 s> Server: testing stub value\r\n
528 s> Server: testing stub value\r\n
512 s> Date: $HTTP_DATE$\r\n
529 s> Date: $HTTP_DATE$\r\n
513 s> Content-Type: application/mercurial-exp-framing-0006\r\n
530 s> Content-Type: application/mercurial-exp-framing-0006\r\n
514 s> Transfer-Encoding: chunked\r\n
531 s> Transfer-Encoding: chunked\r\n
515 s> \r\n
532 s> \r\n
516 s> 11\r\n
533 s> 11\r\n
517 s> \t\x00\x00\x01\x00\x02\x01\x92Hidentity
534 s> \t\x00\x00\x01\x00\x02\x01\x92Hidentity
518 s> \r\n
535 s> \r\n
519 s> 13\r\n
536 s> 13\r\n
520 s> \x0b\x00\x00\x01\x00\x02\x041\xa1FstatusBok
537 s> \x0b\x00\x00\x01\x00\x02\x041\xa1FstatusBok
521 s> \r\n
538 s> \r\n
522 s> 27\r\n
539 s> 27\r\n
523 s> \x1f\x00\x00\x01\x00\x02\x041X\x1dcustomreadonly bytes response
540 s> \x1f\x00\x00\x01\x00\x02\x041X\x1dcustomreadonly bytes response
524 s> \r\n
541 s> \r\n
525 s> 8\r\n
542 s> 8\r\n
526 s> \x00\x00\x00\x01\x00\x02\x002
543 s> \x00\x00\x00\x01\x00\x02\x002
527 s> \r\n
544 s> \r\n
528 s> 13\r\n
545 s> 13\r\n
529 s> \x0b\x00\x00\x03\x00\x02\x041\xa1FstatusBok
546 s> \x0b\x00\x00\x03\x00\x02\x041\xa1FstatusBok
530 s> \r\n
547 s> \r\n
531 s> 27\r\n
548 s> 27\r\n
532 s> \x1f\x00\x00\x03\x00\x02\x041X\x1dcustomreadonly bytes response
549 s> \x1f\x00\x00\x03\x00\x02\x041X\x1dcustomreadonly bytes response
533 s> \r\n
550 s> \r\n
534 s> 8\r\n
551 s> 8\r\n
535 s> \x00\x00\x00\x03\x00\x02\x002
552 s> \x00\x00\x00\x03\x00\x02\x002
536 s> \r\n
553 s> \r\n
537 s> 0\r\n
554 s> 0\r\n
538 s> \r\n
555 s> \r\n
539
556
540 Interleaved requests to "multirequest" are processed
557 Interleaved requests to "multirequest" are processed
541
558
542 $ sendhttpraw << EOF
559 $ sendhttpraw << EOF
543 > httprequest POST api/$HTTPV2/ro/multirequest
560 > httprequest POST api/$HTTPV2/ro/multirequest
544 > accept: $MEDIATYPE
561 > accept: $MEDIATYPE
545 > content-type: $MEDIATYPE
562 > content-type: $MEDIATYPE
546 > user-agent: test
563 > user-agent: test
547 > frame 1 1 stream-begin command-request new|more \xa2Dargs\xa1Inamespace
564 > frame 1 1 stream-begin command-request new|more \xa2Dargs\xa1Inamespace
548 > frame 3 1 0 command-request new|more \xa2Dargs\xa1Inamespace
565 > frame 3 1 0 command-request new|more \xa2Dargs\xa1Inamespace
549 > frame 3 1 0 command-request continuation JnamespacesDnameHlistkeys
566 > frame 3 1 0 command-request continuation JnamespacesDnameHlistkeys
550 > frame 1 1 0 command-request continuation IbookmarksDnameHlistkeys
567 > frame 1 1 0 command-request continuation IbookmarksDnameHlistkeys
551 > EOF
568 > EOF
552 using raw connection to peer
569 using raw connection to peer
570 s> setsockopt(6, 1, 1) -> None (py3 !)
553 s> POST /api/exp-http-v2-0003/ro/multirequest HTTP/1.1\r\n
571 s> POST /api/exp-http-v2-0003/ro/multirequest HTTP/1.1\r\n
554 s> Accept-Encoding: identity\r\n
572 s> Accept-Encoding: identity\r\n
555 s> accept: application/mercurial-exp-framing-0006\r\n
573 s> accept: application/mercurial-exp-framing-0006\r\n
556 s> content-type: application/mercurial-exp-framing-0006\r\n
574 s> content-type: application/mercurial-exp-framing-0006\r\n
557 s> user-agent: test\r\n
575 s> user-agent: test\r\n
558 s> content-length: 115\r\n
576 s> content-length: 115\r\n
559 s> host: $LOCALIP:$HGPORT\r\n (glob)
577 s> host: $LOCALIP:$HGPORT\r\n (glob)
560 s> \r\n
578 s> \r\n
561 s> \x11\x00\x00\x01\x00\x01\x01\x15\xa2Dargs\xa1Inamespace\x11\x00\x00\x03\x00\x01\x00\x15\xa2Dargs\xa1Inamespace\x19\x00\x00\x03\x00\x01\x00\x12JnamespacesDnameHlistkeys\x18\x00\x00\x01\x00\x01\x00\x12IbookmarksDnameHlistkeys
579 s> \x11\x00\x00\x01\x00\x01\x01\x15\xa2Dargs\xa1Inamespace\x11\x00\x00\x03\x00\x01\x00\x15\xa2Dargs\xa1Inamespace\x19\x00\x00\x03\x00\x01\x00\x12JnamespacesDnameHlistkeys\x18\x00\x00\x01\x00\x01\x00\x12IbookmarksDnameHlistkeys
562 s> makefile('rb', None)
580 s> makefile('rb', None)
563 s> HTTP/1.1 200 OK\r\n
581 s> HTTP/1.1 200 OK\r\n
564 s> Server: testing stub value\r\n
582 s> Server: testing stub value\r\n
565 s> Date: $HTTP_DATE$\r\n
583 s> Date: $HTTP_DATE$\r\n
566 s> Content-Type: application/mercurial-exp-framing-0006\r\n
584 s> Content-Type: application/mercurial-exp-framing-0006\r\n
567 s> Transfer-Encoding: chunked\r\n
585 s> Transfer-Encoding: chunked\r\n
568 s> \r\n
586 s> \r\n
569 s> 11\r\n
587 s> 11\r\n
570 s> \t\x00\x00\x03\x00\x02\x01\x92Hidentity
588 s> \t\x00\x00\x03\x00\x02\x01\x92Hidentity
571 s> \r\n
589 s> \r\n
572 s> 13\r\n
590 s> 13\r\n
573 s> \x0b\x00\x00\x03\x00\x02\x041\xa1FstatusBok
591 s> \x0b\x00\x00\x03\x00\x02\x041\xa1FstatusBok
574 s> \r\n
592 s> \r\n
575 s> 28\r\n
593 s> 28\r\n
576 s> \x00\x00\x03\x00\x02\x041\xa3Ibookmarks@Jnamespaces@Fphases@
594 s> \x00\x00\x03\x00\x02\x041\xa3Ibookmarks@Jnamespaces@Fphases@
577 s> \r\n
595 s> \r\n
578 s> 8\r\n
596 s> 8\r\n
579 s> \x00\x00\x00\x03\x00\x02\x002
597 s> \x00\x00\x00\x03\x00\x02\x002
580 s> \r\n
598 s> \r\n
581 s> 13\r\n
599 s> 13\r\n
582 s> \x0b\x00\x00\x01\x00\x02\x041\xa1FstatusBok
600 s> \x0b\x00\x00\x01\x00\x02\x041\xa1FstatusBok
583 s> \r\n
601 s> \r\n
584 s> 9\r\n
602 s> 9\r\n
585 s> \x01\x00\x00\x01\x00\x02\x041\xa0
603 s> \x01\x00\x00\x01\x00\x02\x041\xa0
586 s> \r\n
604 s> \r\n
587 s> 8\r\n
605 s> 8\r\n
588 s> \x00\x00\x00\x01\x00\x02\x002
606 s> \x00\x00\x00\x01\x00\x02\x002
589 s> \r\n
607 s> \r\n
590 s> 0\r\n
608 s> 0\r\n
591 s> \r\n
609 s> \r\n
592
610
593 Restart server to disable read-write access
611 Restart server to disable read-write access
594
612
595 $ killdaemons.py
613 $ killdaemons.py
596 $ cat > server/.hg/hgrc << EOF
614 $ cat > server/.hg/hgrc << EOF
597 > [experimental]
615 > [experimental]
598 > web.apiserver = true
616 > web.apiserver = true
599 > web.api.debugreflect = true
617 > web.api.debugreflect = true
600 > web.api.http-v2 = true
618 > web.api.http-v2 = true
601 > [web]
619 > [web]
602 > push_ssl = false
620 > push_ssl = false
603 > EOF
621 > EOF
604
622
605 $ hg -R server serve -p $HGPORT -d --pid-file hg.pid -E error.log
623 $ hg -R server serve -p $HGPORT -d --pid-file hg.pid -E error.log
606 $ cat hg.pid > $DAEMON_PIDS
624 $ cat hg.pid > $DAEMON_PIDS
607
625
608 Attempting to run a read-write command via multirequest on read-only URL is not allowed
626 Attempting to run a read-write command via multirequest on read-only URL is not allowed
609
627
610 $ sendhttpraw << EOF
628 $ sendhttpraw << EOF
611 > httprequest POST api/$HTTPV2/ro/multirequest
629 > httprequest POST api/$HTTPV2/ro/multirequest
612 > accept: $MEDIATYPE
630 > accept: $MEDIATYPE
613 > content-type: $MEDIATYPE
631 > content-type: $MEDIATYPE
614 > user-agent: test
632 > user-agent: test
615 > frame 1 1 stream-begin command-request new cbor:{b'name': b'pushkey'}
633 > frame 1 1 stream-begin command-request new cbor:{b'name': b'pushkey'}
616 > EOF
634 > EOF
617 using raw connection to peer
635 using raw connection to peer
636 s> setsockopt(6, 1, 1) -> None (py3 !)
618 s> POST /api/exp-http-v2-0003/ro/multirequest HTTP/1.1\r\n
637 s> POST /api/exp-http-v2-0003/ro/multirequest HTTP/1.1\r\n
619 s> Accept-Encoding: identity\r\n
638 s> Accept-Encoding: identity\r\n
620 s> accept: application/mercurial-exp-framing-0006\r\n
639 s> accept: application/mercurial-exp-framing-0006\r\n
621 s> content-type: application/mercurial-exp-framing-0006\r\n
640 s> content-type: application/mercurial-exp-framing-0006\r\n
622 s> user-agent: test\r\n
641 s> user-agent: test\r\n
623 s> content-length: 22\r\n
642 s> content-length: 22\r\n
624 s> host: $LOCALIP:$HGPORT\r\n (glob)
643 s> host: $LOCALIP:$HGPORT\r\n (glob)
625 s> \r\n
644 s> \r\n
626 s> \x0e\x00\x00\x01\x00\x01\x01\x11\xa1DnameGpushkey
645 s> \x0e\x00\x00\x01\x00\x01\x01\x11\xa1DnameGpushkey
627 s> makefile('rb', None)
646 s> makefile('rb', None)
628 s> HTTP/1.1 403 Forbidden\r\n
647 s> HTTP/1.1 403 Forbidden\r\n
629 s> Server: testing stub value\r\n
648 s> Server: testing stub value\r\n
630 s> Date: $HTTP_DATE$\r\n
649 s> Date: $HTTP_DATE$\r\n
631 s> Content-Type: text/plain\r\n
650 s> Content-Type: text/plain\r\n
632 s> Content-Length: 52\r\n
651 s> Content-Length: 52\r\n
633 s> \r\n
652 s> \r\n
634 s> insufficient permissions to execute command: pushkey
653 s> insufficient permissions to execute command: pushkey
635
654
636 Defining an invalid content encoding results in warning
655 Defining an invalid content encoding results in warning
637
656
638 $ hg --config experimental.httppeer.v2-encoder-order=identity,badencoder --verbose debugwireproto --nologhandshake --peer http2 http://$LOCALIP:$HGPORT/ << EOF
657 $ hg --config experimental.httppeer.v2-encoder-order=identity,badencoder --verbose debugwireproto --nologhandshake --peer http2 http://$LOCALIP:$HGPORT/ << EOF
639 > command heads
658 > command heads
640 > EOF
659 > EOF
641 creating http peer for wire protocol version 2
660 creating http peer for wire protocol version 2
642 sending heads command
661 sending heads command
643 wire protocol version 2 encoder referenced in config (badencoder) is not known; ignoring
662 wire protocol version 2 encoder referenced in config (badencoder) is not known; ignoring
663 s> setsockopt(6, 1, 1) -> None (py3 !)
644 s> POST /api/exp-http-v2-0003/ro/heads HTTP/1.1\r\n
664 s> POST /api/exp-http-v2-0003/ro/heads HTTP/1.1\r\n
645 s> Accept-Encoding: identity\r\n
665 s> Accept-Encoding: identity\r\n
646 s> accept: application/mercurial-exp-framing-0006\r\n
666 s> accept: application/mercurial-exp-framing-0006\r\n
647 s> content-type: application/mercurial-exp-framing-0006\r\n
667 s> content-type: application/mercurial-exp-framing-0006\r\n
648 s> content-length: 56\r\n
668 s> content-length: 56\r\n
649 s> host: $LOCALIP:$HGPORT\r\n (glob)
669 s> host: $LOCALIP:$HGPORT\r\n (glob)
650 s> user-agent: Mercurial debugwireproto\r\n
670 s> user-agent: Mercurial debugwireproto\r\n
651 s> \r\n
671 s> \r\n
652 s> \x1c\x00\x00\x01\x00\x01\x01\x82\xa1Pcontentencodings\x81Hidentity\x0c\x00\x00\x01\x00\x01\x00\x11\xa1DnameEheads
672 s> \x1c\x00\x00\x01\x00\x01\x01\x82\xa1Pcontentencodings\x81Hidentity\x0c\x00\x00\x01\x00\x01\x00\x11\xa1DnameEheads
653 s> makefile('rb', None)
673 s> makefile('rb', None)
654 s> HTTP/1.1 200 OK\r\n
674 s> HTTP/1.1 200 OK\r\n
655 s> Server: testing stub value\r\n
675 s> Server: testing stub value\r\n
656 s> Date: $HTTP_DATE$\r\n
676 s> Date: $HTTP_DATE$\r\n
657 s> Content-Type: application/mercurial-exp-framing-0006\r\n
677 s> Content-Type: application/mercurial-exp-framing-0006\r\n
658 s> Transfer-Encoding: chunked\r\n
678 s> Transfer-Encoding: chunked\r\n
659 s> \r\n
679 s> \r\n
660 s> 11\r\n
680 s> 11\r\n
661 s> \t\x00\x00\x01\x00\x02\x01\x92
681 s> \t\x00\x00\x01\x00\x02\x01\x92
662 s> Hidentity
682 s> Hidentity
663 s> \r\n
683 s> \r\n
664 s> 13\r\n
684 s> 13\r\n
665 s> \x0b\x00\x00\x01\x00\x02\x041
685 s> \x0b\x00\x00\x01\x00\x02\x041
666 s> \xa1FstatusBok
686 s> \xa1FstatusBok
667 s> \r\n
687 s> \r\n
668 s> 1e\r\n
688 s> 1e\r\n
669 s> \x16\x00\x00\x01\x00\x02\x041
689 s> \x16\x00\x00\x01\x00\x02\x041
670 s> \x81T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
690 s> \x81T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
671 s> \r\n
691 s> \r\n
672 s> 8\r\n
692 s> 8\r\n
673 s> \x00\x00\x00\x01\x00\x02\x002
693 s> \x00\x00\x00\x01\x00\x02\x002
674 s> \r\n
694 s> \r\n
675 s> 0\r\n
695 s> 0\r\n
676 s> \r\n
696 s> \r\n
677 response: [
697 response: [
678 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
698 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
679 ]
699 ]
680 (sent 2 HTTP requests and * bytes; received * bytes in responses) (glob)
700 (sent 2 HTTP requests and * bytes; received * bytes in responses) (glob)
681
701
682 #if zstd
702 #if zstd
683
703
684 $ hg --verbose debugwireproto --nologhandshake --peer http2 http://$LOCALIP:$HGPORT/ << EOF
704 $ hg --verbose debugwireproto --nologhandshake --peer http2 http://$LOCALIP:$HGPORT/ << EOF
685 > command heads
705 > command heads
686 > EOF
706 > EOF
687 creating http peer for wire protocol version 2
707 creating http peer for wire protocol version 2
688 sending heads command
708 sending heads command
709 s> setsockopt(6, 1, 1) -> None (py3 !)
689 s> POST /api/exp-http-v2-0003/ro/heads HTTP/1.1\r\n
710 s> POST /api/exp-http-v2-0003/ro/heads HTTP/1.1\r\n
690 s> Accept-Encoding: identity\r\n
711 s> Accept-Encoding: identity\r\n
691 s> accept: application/mercurial-exp-framing-0006\r\n
712 s> accept: application/mercurial-exp-framing-0006\r\n
692 s> content-type: application/mercurial-exp-framing-0006\r\n
713 s> content-type: application/mercurial-exp-framing-0006\r\n
693 s> content-length: 70\r\n
714 s> content-length: 70\r\n
694 s> host: $LOCALIP:$HGPORT\r\n (glob)
715 s> host: $LOCALIP:$HGPORT\r\n (glob)
695 s> user-agent: Mercurial debugwireproto\r\n
716 s> user-agent: Mercurial debugwireproto\r\n
696 s> \r\n
717 s> \r\n
697 s> *\x00\x00\x01\x00\x01\x01\x82\xa1Pcontentencodings\x83Hzstd-8mbDzlibHidentity\x0c\x00\x00\x01\x00\x01\x00\x11\xa1DnameEheads
718 s> *\x00\x00\x01\x00\x01\x01\x82\xa1Pcontentencodings\x83Hzstd-8mbDzlibHidentity\x0c\x00\x00\x01\x00\x01\x00\x11\xa1DnameEheads
698 s> makefile('rb', None)
719 s> makefile('rb', None)
699 s> HTTP/1.1 200 OK\r\n
720 s> HTTP/1.1 200 OK\r\n
700 s> Server: testing stub value\r\n
721 s> Server: testing stub value\r\n
701 s> Date: $HTTP_DATE$\r\n
722 s> Date: $HTTP_DATE$\r\n
702 s> Content-Type: application/mercurial-exp-framing-0006\r\n
723 s> Content-Type: application/mercurial-exp-framing-0006\r\n
703 s> Transfer-Encoding: chunked\r\n
724 s> Transfer-Encoding: chunked\r\n
704 s> \r\n
725 s> \r\n
705 s> 11\r\n
726 s> 11\r\n
706 s> \t\x00\x00\x01\x00\x02\x01\x92
727 s> \t\x00\x00\x01\x00\x02\x01\x92
707 s> Hzstd-8mb
728 s> Hzstd-8mb
708 s> \r\n
729 s> \r\n
709 s> 25\r\n
730 s> 25\r\n
710 s> \x1d\x00\x00\x01\x00\x02\x042
731 s> \x1d\x00\x00\x01\x00\x02\x042
711 s> (\xb5/\xfd\x00P\xa4\x00\x00p\xa1FstatusBok\x81T\x00\x01\x00\tP\x02
732 s> (\xb5/\xfd\x00P\xa4\x00\x00p\xa1FstatusBok\x81T\x00\x01\x00\tP\x02
712 s> \r\n
733 s> \r\n
713 s> 0\r\n
734 s> 0\r\n
714 s> \r\n
735 s> \r\n
715 response: [
736 response: [
716 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
737 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
717 ]
738 ]
718 (sent 2 HTTP requests and * bytes; received * bytes in responses) (glob)
739 (sent 2 HTTP requests and * bytes; received * bytes in responses) (glob)
719
740
720 #endif
741 #endif
721
742
722 $ cat error.log
743 $ cat error.log
General Comments 0
You need to be logged in to leave comments. Login now