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