##// END OF EJS Templates
tests: add b'' prefixes to ui.configbool() call...
Gregory Szorc -
r41428:0cfbe78f default
parent child Browse files
Show More
@@ -1,773 +1,773 b''
1 1 #require no-chg
2 2
3 3 $ . $TESTDIR/wireprotohelpers.sh
4 4
5 5 $ cat >> $HGRCPATH << EOF
6 6 > [web]
7 7 > push_ssl = false
8 8 > allow_push = *
9 9 > EOF
10 10
11 11 $ hg init server
12 12 $ cd server
13 13 $ touch a
14 14 $ hg -q commit -A -m initial
15 15 $ cd ..
16 16
17 17 $ hg serve -R server -p $HGPORT -d --pid-file hg.pid
18 18 $ cat hg.pid >> $DAEMON_PIDS
19 19
20 20 compression formats are advertised in compression capability
21 21
22 22 #if zstd
23 23 $ get-with-headers.py $LOCALIP:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep '^compression=zstd,zlib$' > /dev/null
24 24 #else
25 25 $ get-with-headers.py $LOCALIP:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep '^compression=zlib$' > /dev/null
26 26 #endif
27 27
28 28 $ killdaemons.py
29 29
30 30 server.compressionengines can replace engines list wholesale
31 31
32 32 $ hg serve --config server.compressionengines=none -R server -p $HGPORT -d --pid-file hg.pid
33 33 $ cat hg.pid > $DAEMON_PIDS
34 34 $ get-with-headers.py $LOCALIP:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep '^compression=none$' > /dev/null
35 35
36 36 $ killdaemons.py
37 37
38 38 Order of engines can also change
39 39
40 40 $ hg serve --config server.compressionengines=none,zlib -R server -p $HGPORT -d --pid-file hg.pid
41 41 $ cat hg.pid > $DAEMON_PIDS
42 42 $ get-with-headers.py $LOCALIP:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep '^compression=none,zlib$' > /dev/null
43 43
44 44 $ killdaemons.py
45 45
46 46 Start a default server again
47 47
48 48 $ hg serve -R server -p $HGPORT -d --pid-file hg.pid
49 49 $ cat hg.pid > $DAEMON_PIDS
50 50
51 51 Server should send application/mercurial-0.1 to clients if no Accept is used
52 52
53 53 $ get-with-headers.py --headeronly $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' -
54 54 200 Script output follows
55 55 content-type: application/mercurial-0.1
56 56 date: $HTTP_DATE$
57 57 server: testing stub value
58 58 transfer-encoding: chunked
59 59
60 60 Server should send application/mercurial-0.1 when client says it wants it
61 61
62 62 $ get-with-headers.py --hgproto '0.1' --headeronly $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' -
63 63 200 Script output follows
64 64 content-type: application/mercurial-0.1
65 65 date: $HTTP_DATE$
66 66 server: testing stub value
67 67 transfer-encoding: chunked
68 68
69 69 Server should send application/mercurial-0.2 when client says it wants it
70 70
71 71 $ get-with-headers.py --hgproto '0.2' --headeronly $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' -
72 72 200 Script output follows
73 73 content-type: application/mercurial-0.2
74 74 date: $HTTP_DATE$
75 75 server: testing stub value
76 76 transfer-encoding: chunked
77 77
78 78 $ get-with-headers.py --hgproto '0.1 0.2' --headeronly $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' -
79 79 200 Script output follows
80 80 content-type: application/mercurial-0.2
81 81 date: $HTTP_DATE$
82 82 server: testing stub value
83 83 transfer-encoding: chunked
84 84
85 85 Requesting a compression format that server doesn't support results will fall back to 0.1
86 86
87 87 $ get-with-headers.py --hgproto '0.2 comp=aa' --headeronly $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' -
88 88 200 Script output follows
89 89 content-type: application/mercurial-0.1
90 90 date: $HTTP_DATE$
91 91 server: testing stub value
92 92 transfer-encoding: chunked
93 93
94 94 #if zstd
95 95 zstd is used if available
96 96
97 97 $ get-with-headers.py --hgproto '0.2 comp=zstd' $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' > resp
98 98 $ f --size --hexdump --bytes 36 --sha1 resp
99 99 resp: size=248, sha1=4d8d8f87fb82bd542ce52881fdc94f850748
100 100 0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
101 101 0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 04 7a 73 74 64 |t follows...zstd|
102 102 0020: 28 b5 2f fd |(./.|
103 103
104 104 #endif
105 105
106 106 application/mercurial-0.2 is not yet used on non-streaming responses
107 107
108 108 $ get-with-headers.py --hgproto '0.2' $LOCALIP:$HGPORT '?cmd=heads' -
109 109 200 Script output follows
110 110 content-length: 41
111 111 content-type: application/mercurial-0.1
112 112 date: $HTTP_DATE$
113 113 server: testing stub value
114 114
115 115 e93700bd72895c5addab234c56d4024b487a362f
116 116
117 117 Now test protocol preference usage
118 118
119 119 $ killdaemons.py
120 120 $ hg serve --config server.compressionengines=none,zlib -R server -p $HGPORT -d --pid-file hg.pid
121 121 $ cat hg.pid > $DAEMON_PIDS
122 122
123 123 No Accept will send 0.1+zlib, even though "none" is preferred b/c "none" isn't supported on 0.1
124 124
125 125 $ get-with-headers.py --headeronly $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' Content-Type
126 126 200 Script output follows
127 127 content-type: application/mercurial-0.1
128 128
129 129 $ get-with-headers.py $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' > resp
130 130 $ f --size --hexdump --bytes 28 --sha1 resp
131 131 resp: size=227, sha1=35a4c074da74f32f5440da3cbf04
132 132 0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
133 133 0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 78 |t follows..x|
134 134
135 135 Explicit 0.1 will send zlib because "none" isn't supported on 0.1
136 136
137 137 $ get-with-headers.py --hgproto '0.1' $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' > resp
138 138 $ f --size --hexdump --bytes 28 --sha1 resp
139 139 resp: size=227, sha1=35a4c074da74f32f5440da3cbf04
140 140 0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
141 141 0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 78 |t follows..x|
142 142
143 143 0.2 with no compression will get "none" because that is server's preference
144 144 (spec says ZL and UN are implicitly supported)
145 145
146 146 $ get-with-headers.py --hgproto '0.2' $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' > resp
147 147 $ f --size --hexdump --bytes 32 --sha1 resp
148 148 resp: size=432, sha1=ac931b412ec185a02e0e5bcff98dac83
149 149 0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
150 150 0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 04 6e 6f 6e 65 |t follows...none|
151 151
152 152 Client receives server preference even if local order doesn't match
153 153
154 154 $ get-with-headers.py --hgproto '0.2 comp=zlib,none' $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' > resp
155 155 $ f --size --hexdump --bytes 32 --sha1 resp
156 156 resp: size=432, sha1=ac931b412ec185a02e0e5bcff98dac83
157 157 0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
158 158 0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 04 6e 6f 6e 65 |t follows...none|
159 159
160 160 Client receives only supported format even if not server preferred format
161 161
162 162 $ get-with-headers.py --hgproto '0.2 comp=zlib' $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' > resp
163 163 $ f --size --hexdump --bytes 33 --sha1 resp
164 164 resp: size=232, sha1=a1c727f0c9693ca15742a75c30419bc36
165 165 0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
166 166 0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 04 7a 6c 69 62 |t follows...zlib|
167 167 0020: 78 |x|
168 168
169 169 $ killdaemons.py
170 170 $ cd ..
171 171
172 172 Test listkeys for listing namespaces
173 173
174 174 $ hg init empty
175 175 $ hg -R empty serve -p $HGPORT -d --pid-file hg.pid
176 176 $ cat hg.pid > $DAEMON_PIDS
177 177
178 178 $ hg --verbose debugwireproto http://$LOCALIP:$HGPORT << EOF
179 179 > command listkeys
180 180 > namespace namespaces
181 181 > EOF
182 182 s> setsockopt(6, 1, 1) -> None (py3 !)
183 183 s> GET /?cmd=capabilities HTTP/1.1\r\n
184 184 s> Accept-Encoding: identity\r\n
185 185 s> accept: application/mercurial-0.1\r\n
186 186 s> host: $LOCALIP:$HGPORT\r\n (glob)
187 187 s> user-agent: Mercurial debugwireproto\r\n
188 188 s> \r\n
189 189 s> makefile('rb', None)
190 190 s> HTTP/1.1 200 Script output follows\r\n
191 191 s> Server: testing stub value\r\n
192 192 s> Date: $HTTP_DATE$\r\n
193 193 s> Content-Type: application/mercurial-0.1\r\n
194 194 s> Content-Length: *\r\n (glob)
195 195 s> \r\n
196 196 s> batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
197 197 sending listkeys command
198 198 s> setsockopt(6, 1, 1) -> None (py3 !)
199 199 s> GET /?cmd=listkeys HTTP/1.1\r\n
200 200 s> Accept-Encoding: identity\r\n
201 201 s> vary: X-HgArg-1,X-HgProto-1\r\n
202 202 s> x-hgarg-1: namespace=namespaces\r\n
203 203 s> x-hgproto-1: 0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull\r\n
204 204 s> accept: application/mercurial-0.1\r\n
205 205 s> host: $LOCALIP:$HGPORT\r\n (glob)
206 206 s> user-agent: Mercurial debugwireproto\r\n
207 207 s> \r\n
208 208 s> makefile('rb', None)
209 209 s> HTTP/1.1 200 Script output follows\r\n
210 210 s> Server: testing stub value\r\n
211 211 s> Date: $HTTP_DATE$\r\n
212 212 s> Content-Type: application/mercurial-0.1\r\n
213 213 s> Content-Length: 30\r\n
214 214 s> \r\n
215 215 s> bookmarks\t\n
216 216 s> namespaces\t\n
217 217 s> phases\t
218 218 response: {
219 219 b'bookmarks': b'',
220 220 b'namespaces': b'',
221 221 b'phases': b''
222 222 }
223 223 (sent 2 HTTP requests and * bytes; received * bytes in responses) (glob)
224 224
225 225 Same thing, but with "httprequest" command
226 226
227 227 $ hg --verbose debugwireproto --peer raw http://$LOCALIP:$HGPORT << EOF
228 228 > httprequest GET ?cmd=listkeys
229 229 > user-agent: test
230 230 > x-hgarg-1: namespace=namespaces
231 231 > EOF
232 232 using raw connection to peer
233 233 s> setsockopt(6, 1, 1) -> None (py3 !)
234 234 s> GET /?cmd=listkeys HTTP/1.1\r\n
235 235 s> Accept-Encoding: identity\r\n
236 236 s> user-agent: test\r\n
237 237 s> x-hgarg-1: namespace=namespaces\r\n
238 238 s> host: $LOCALIP:$HGPORT\r\n (glob)
239 239 s> \r\n
240 240 s> makefile('rb', None)
241 241 s> HTTP/1.1 200 Script output follows\r\n
242 242 s> Server: testing stub value\r\n
243 243 s> Date: $HTTP_DATE$\r\n
244 244 s> Content-Type: application/mercurial-0.1\r\n
245 245 s> Content-Length: 30\r\n
246 246 s> \r\n
247 247 s> bookmarks\t\n
248 248 s> namespaces\t\n
249 249 s> phases\t
250 250
251 251 Client with HTTPv2 enabled advertises that and gets old capabilities response from old server
252 252
253 253 $ hg --config experimental.httppeer.advertise-v2=true --verbose debugwireproto http://$LOCALIP:$HGPORT << EOF
254 254 > command heads
255 255 > EOF
256 256 s> setsockopt(6, 1, 1) -> None (py3 !)
257 257 s> GET /?cmd=capabilities HTTP/1.1\r\n
258 258 s> Accept-Encoding: identity\r\n
259 259 s> vary: X-HgProto-1,X-HgUpgrade-1\r\n
260 260 s> x-hgproto-1: cbor\r\n
261 261 s> x-hgupgrade-1: exp-http-v2-0003\r\n
262 262 s> accept: application/mercurial-0.1\r\n
263 263 s> host: $LOCALIP:$HGPORT\r\n (glob)
264 264 s> user-agent: Mercurial debugwireproto\r\n
265 265 s> \r\n
266 266 s> makefile('rb', None)
267 267 s> HTTP/1.1 200 Script output follows\r\n
268 268 s> Server: testing stub value\r\n
269 269 s> Date: $HTTP_DATE$\r\n
270 270 s> Content-Type: application/mercurial-0.1\r\n
271 271 s> Content-Length: *\r\n (glob)
272 272 s> \r\n
273 273 s> batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
274 274 sending heads command
275 275 s> setsockopt(6, 1, 1) -> None (py3 !)
276 276 s> GET /?cmd=heads HTTP/1.1\r\n
277 277 s> Accept-Encoding: identity\r\n
278 278 s> vary: X-HgProto-1\r\n
279 279 s> x-hgproto-1: 0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull\r\n
280 280 s> accept: application/mercurial-0.1\r\n
281 281 s> host: $LOCALIP:$HGPORT\r\n (glob)
282 282 s> user-agent: Mercurial debugwireproto\r\n
283 283 s> \r\n
284 284 s> makefile('rb', None)
285 285 s> HTTP/1.1 200 Script output follows\r\n
286 286 s> Server: testing stub value\r\n
287 287 s> Date: $HTTP_DATE$\r\n
288 288 s> Content-Type: application/mercurial-0.1\r\n
289 289 s> Content-Length: 41\r\n
290 290 s> \r\n
291 291 s> 0000000000000000000000000000000000000000\n
292 292 response: [
293 293 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
294 294 ]
295 295 (sent 2 HTTP requests and * bytes; received * bytes in responses) (glob)
296 296
297 297 $ killdaemons.py
298 298 $ enablehttpv2 empty
299 299 $ hg --config server.compressionengines=zlib -R empty serve -p $HGPORT -d --pid-file hg.pid
300 300 $ cat hg.pid > $DAEMON_PIDS
301 301
302 302 Client with HTTPv2 enabled automatically upgrades if the server supports it
303 303
304 304 $ hg --config experimental.httppeer.advertise-v2=true --config experimental.httppeer.v2-encoder-order=identity --verbose debugwireproto http://$LOCALIP:$HGPORT << EOF
305 305 > command heads
306 306 > EOF
307 307 s> setsockopt(6, 1, 1) -> None (py3 !)
308 308 s> GET /?cmd=capabilities HTTP/1.1\r\n
309 309 s> Accept-Encoding: identity\r\n
310 310 s> vary: X-HgProto-1,X-HgUpgrade-1\r\n
311 311 s> x-hgproto-1: cbor\r\n
312 312 s> x-hgupgrade-1: exp-http-v2-0003\r\n
313 313 s> accept: application/mercurial-0.1\r\n
314 314 s> host: $LOCALIP:$HGPORT\r\n (glob)
315 315 s> user-agent: Mercurial debugwireproto\r\n
316 316 s> \r\n
317 317 s> makefile('rb', None)
318 318 s> HTTP/1.1 200 OK\r\n
319 319 s> Server: testing stub value\r\n
320 320 s> Date: $HTTP_DATE$\r\n
321 321 s> Content-Type: application/mercurial-cbor\r\n
322 322 s> Content-Length: *\r\n (glob)
323 323 s> \r\n
324 324 s> \xa3GapibaseDapi/Dapis\xa1Pexp-http-v2-0003\xa4Hcommands\xacIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullMchangesetdata\xa2Dargs\xa2Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x84IbookmarksGparentsEphaseHrevisionIrevisions\xa2Hrequired\xf5DtypeDlistKpermissions\x81DpullHfiledata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x83HlinknodeGparentsHrevisionKhaveparents\xa3Gdefault\xf4Hrequired\xf4DtypeDboolEnodes\xa2Hrequired\xf5DtypeDlistDpath\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullIfilesdata\xa3Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x84NfirstchangesetHlinknodeGparentsHrevisionKhaveparents\xa3Gdefault\xf4Hrequired\xf4DtypeDboolJpathfilter\xa3Gdefault\xf6Hrequired\xf4DtypeDdictIrevisions\xa2Hrequired\xf5DtypeDlistKpermissions\x81DpullTrecommendedbatchsize\x19\xc3PEheads\xa2Dargs\xa1Jpubliconly\xa3Gdefault\xf4Hrequired\xf4DtypeDboolKpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\xa3Gdefault\x80Hrequired\xf4DtypeDlistKpermissions\x81DpullHlistkeys\xa2Dargs\xa1Inamespace\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullFlookup\xa2Dargs\xa1Ckey\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullLmanifestdata\xa3Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x82GparentsHrevisionKhaveparents\xa3Gdefault\xf4Hrequired\xf4DtypeDboolEnodes\xa2Hrequired\xf5DtypeDlistDtree\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullTrecommendedbatchsize\x1a\x00\x01\x86\xa0Gpushkey\xa2Dargs\xa4Ckey\xa2Hrequired\xf5DtypeEbytesInamespace\xa2Hrequired\xf5DtypeEbytesCnew\xa2Hrequired\xf5DtypeEbytesCold\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpushPrawstorefiledata\xa2Dargs\xa2Efiles\xa2Hrequired\xf5DtypeDlistJpathfilter\xa3Gdefault\xf6Hrequired\xf4DtypeDlistKpermissions\x81DpullQframingmediatypes\x81X&application/mercurial-exp-framing-0006Rpathfilterprefixes\xd9\x01\x02\x82Epath:Lrootfilesin:Nrawrepoformats\x83LgeneraldeltaHrevlogv1LsparserevlogNv1capabilitiesY\x01\xe0batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
325 325 sending heads command
326 326 s> setsockopt(6, 1, 1) -> None (py3 !)
327 327 s> POST /api/exp-http-v2-0003/ro/heads HTTP/1.1\r\n
328 328 s> Accept-Encoding: identity\r\n
329 329 s> accept: application/mercurial-exp-framing-0006\r\n
330 330 s> content-type: application/mercurial-exp-framing-0006\r\n
331 331 s> content-length: 56\r\n
332 332 s> host: $LOCALIP:$HGPORT\r\n (glob)
333 333 s> user-agent: Mercurial debugwireproto\r\n
334 334 s> \r\n
335 335 s> \x1c\x00\x00\x01\x00\x01\x01\x82\xa1Pcontentencodings\x81Hidentity\x0c\x00\x00\x01\x00\x01\x00\x11\xa1DnameEheads
336 336 s> makefile('rb', None)
337 337 s> HTTP/1.1 200 OK\r\n
338 338 s> Server: testing stub value\r\n
339 339 s> Date: $HTTP_DATE$\r\n
340 340 s> Content-Type: application/mercurial-exp-framing-0006\r\n
341 341 s> Transfer-Encoding: chunked\r\n
342 342 s> \r\n
343 343 s> 11\r\n
344 344 s> \t\x00\x00\x01\x00\x02\x01\x92
345 345 s> Hidentity
346 346 s> \r\n
347 347 s> 13\r\n
348 348 s> \x0b\x00\x00\x01\x00\x02\x041
349 349 s> \xa1FstatusBok
350 350 s> \r\n
351 351 s> 1e\r\n
352 352 s> \x16\x00\x00\x01\x00\x02\x041
353 353 s> \x81T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
354 354 s> \r\n
355 355 s> 8\r\n
356 356 s> \x00\x00\x00\x01\x00\x02\x002
357 357 s> \r\n
358 358 s> 0\r\n
359 359 s> \r\n
360 360 response: [
361 361 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
362 362 ]
363 363 (sent 2 HTTP requests and * bytes; received * bytes in responses) (glob)
364 364
365 365 $ killdaemons.py
366 366
367 367 HTTP client follows HTTP redirect on handshake to new repo
368 368
369 369 $ cd $TESTTMP
370 370
371 371 $ hg init redirector
372 372 $ hg init redirected
373 373 $ cd redirected
374 374 $ touch foo
375 375 $ hg -q commit -A -m initial
376 376 $ cd ..
377 377
378 378 $ cat > paths.conf << EOF
379 379 > [paths]
380 380 > / = $TESTTMP/*
381 381 > EOF
382 382
383 383 $ cat > redirectext.py << EOF
384 384 > from mercurial import extensions, wireprotoserver
385 385 > def wrappedcallhttp(orig, repo, req, res, proto, cmd):
386 386 > path = req.advertisedurl[len(req.advertisedbaseurl):]
387 387 > if not path.startswith(b'/redirector'):
388 388 > return orig(repo, req, res, proto, cmd)
389 389 > relpath = path[len(b'/redirector'):]
390 390 > res.status = b'301 Redirect'
391 391 > newurl = b'%s/redirected%s' % (req.baseurl, relpath)
392 > if not repo.ui.configbool('testing', 'redirectqs', True) and b'?' in newurl:
392 > if not repo.ui.configbool(b'testing', b'redirectqs', True) and b'?' in newurl:
393 393 > newurl = newurl[0:newurl.index(b'?')]
394 394 > res.headers[b'Location'] = newurl
395 395 > res.headers[b'Content-Type'] = b'text/plain'
396 396 > res.setbodybytes(b'redirected')
397 397 > return True
398 398 >
399 399 > extensions.wrapfunction(wireprotoserver, '_callhttp', wrappedcallhttp)
400 400 > EOF
401 401
402 402 $ hg --config extensions.redirect=$TESTTMP/redirectext.py \
403 403 > --config server.compressionengines=zlib \
404 404 > serve --web-conf paths.conf --pid-file hg.pid -p $HGPORT -d
405 405 $ cat hg.pid > $DAEMON_PIDS
406 406
407 407 Verify our HTTP 301 is served properly
408 408
409 409 $ hg --verbose debugwireproto --peer raw http://$LOCALIP:$HGPORT << EOF
410 410 > httprequest GET /redirector?cmd=capabilities
411 411 > user-agent: test
412 412 > EOF
413 413 using raw connection to peer
414 414 s> setsockopt(6, 1, 1) -> None (py3 !)
415 415 s> GET /redirector?cmd=capabilities HTTP/1.1\r\n
416 416 s> Accept-Encoding: identity\r\n
417 417 s> user-agent: test\r\n
418 418 s> host: $LOCALIP:$HGPORT\r\n (glob)
419 419 s> \r\n
420 420 s> makefile('rb', None)
421 421 s> HTTP/1.1 301 Redirect\r\n
422 422 s> Server: testing stub value\r\n
423 423 s> Date: $HTTP_DATE$\r\n
424 424 s> Location: http://$LOCALIP:$HGPORT/redirected?cmd=capabilities\r\n (glob)
425 425 s> Content-Type: text/plain\r\n
426 426 s> Content-Length: 10\r\n
427 427 s> \r\n
428 428 s> redirected
429 429 s> setsockopt(6, 1, 1) -> None (py3 !)
430 430 s> GET /redirected?cmd=capabilities HTTP/1.1\r\n
431 431 s> Accept-Encoding: identity\r\n
432 432 s> user-agent: test\r\n
433 433 s> host: $LOCALIP:$HGPORT\r\n (glob)
434 434 s> \r\n
435 435 s> makefile('rb', None)
436 436 s> HTTP/1.1 200 Script output follows\r\n
437 437 s> Server: testing stub value\r\n
438 438 s> Date: $HTTP_DATE$\r\n
439 439 s> Content-Type: application/mercurial-0.1\r\n
440 440 s> Content-Length: 480\r\n
441 441 s> \r\n
442 442 s> batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
443 443
444 444 Test with the HTTP peer
445 445
446 446 $ hg --verbose debugwireproto http://$LOCALIP:$HGPORT/redirector << EOF
447 447 > command heads
448 448 > EOF
449 449 s> setsockopt(6, 1, 1) -> None (py3 !)
450 450 s> GET /redirector?cmd=capabilities HTTP/1.1\r\n
451 451 s> Accept-Encoding: identity\r\n
452 452 s> accept: application/mercurial-0.1\r\n
453 453 s> host: $LOCALIP:$HGPORT\r\n (glob)
454 454 s> user-agent: Mercurial debugwireproto\r\n
455 455 s> \r\n
456 456 s> makefile('rb', None)
457 457 s> HTTP/1.1 301 Redirect\r\n
458 458 s> Server: testing stub value\r\n
459 459 s> Date: $HTTP_DATE$\r\n
460 460 s> Location: http://$LOCALIP:$HGPORT/redirected?cmd=capabilities\r\n (glob)
461 461 s> Content-Type: text/plain\r\n
462 462 s> Content-Length: 10\r\n
463 463 s> \r\n
464 464 s> redirected
465 465 s> setsockopt(6, 1, 1) -> None (py3 !)
466 466 s> GET /redirected?cmd=capabilities HTTP/1.1\r\n
467 467 s> Accept-Encoding: identity\r\n
468 468 s> accept: application/mercurial-0.1\r\n
469 469 s> host: $LOCALIP:$HGPORT\r\n (glob)
470 470 s> user-agent: Mercurial debugwireproto\r\n
471 471 s> \r\n
472 472 s> makefile('rb', None)
473 473 s> HTTP/1.1 200 Script output follows\r\n
474 474 s> Server: testing stub value\r\n
475 475 s> Date: $HTTP_DATE$\r\n
476 476 s> Content-Type: application/mercurial-0.1\r\n
477 477 s> Content-Length: 480\r\n
478 478 s> \r\n
479 479 real URL is http://$LOCALIP:$HGPORT/redirected (glob)
480 480 s> batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
481 481 sending heads command
482 482 s> setsockopt(6, 1, 1) -> None (py3 !)
483 483 s> GET /redirected?cmd=heads HTTP/1.1\r\n
484 484 s> Accept-Encoding: identity\r\n
485 485 s> vary: X-HgProto-1\r\n
486 486 s> x-hgproto-1: 0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull\r\n
487 487 s> accept: application/mercurial-0.1\r\n
488 488 s> host: $LOCALIP:$HGPORT\r\n (glob)
489 489 s> user-agent: Mercurial debugwireproto\r\n
490 490 s> \r\n
491 491 s> makefile('rb', None)
492 492 s> HTTP/1.1 200 Script output follows\r\n
493 493 s> Server: testing stub value\r\n
494 494 s> Date: $HTTP_DATE$\r\n
495 495 s> Content-Type: application/mercurial-0.1\r\n
496 496 s> Content-Length: 41\r\n
497 497 s> \r\n
498 498 s> 96ee1d7354c4ad7372047672c36a1f561e3a6a4c\n
499 499 response: [
500 500 b'\x96\xee\x1dsT\xc4\xadsr\x04vr\xc3j\x1fV\x1e:jL'
501 501 ]
502 502 (sent 3 HTTP requests and * bytes; received * bytes in responses) (glob)
503 503
504 504 $ killdaemons.py
505 505
506 506 Now test a variation where we strip the query string from the redirect URL.
507 507 (SCM Manager apparently did this and clients would recover from it)
508 508
509 509 $ hg --config extensions.redirect=$TESTTMP/redirectext.py \
510 510 > --config server.compressionengines=zlib \
511 511 > --config testing.redirectqs=false \
512 512 > serve --web-conf paths.conf --pid-file hg.pid -p $HGPORT -d
513 513 $ cat hg.pid > $DAEMON_PIDS
514 514
515 515 $ hg --verbose debugwireproto --peer raw http://$LOCALIP:$HGPORT << EOF
516 516 > httprequest GET /redirector?cmd=capabilities
517 517 > user-agent: test
518 518 > EOF
519 519 using raw connection to peer
520 520 s> setsockopt(6, 1, 1) -> None (py3 !)
521 521 s> GET /redirector?cmd=capabilities HTTP/1.1\r\n
522 522 s> Accept-Encoding: identity\r\n
523 523 s> user-agent: test\r\n
524 524 s> host: $LOCALIP:$HGPORT\r\n (glob)
525 525 s> \r\n
526 526 s> makefile('rb', None)
527 527 s> HTTP/1.1 301 Redirect\r\n
528 528 s> Server: testing stub value\r\n
529 529 s> Date: $HTTP_DATE$\r\n
530 530 s> Location: http://$LOCALIP:$HGPORT/redirected\r\n (glob)
531 531 s> Content-Type: text/plain\r\n
532 532 s> Content-Length: 10\r\n
533 533 s> \r\n
534 534 s> redirected
535 535 s> setsockopt(6, 1, 1) -> None (py3 !)
536 536 s> GET /redirected HTTP/1.1\r\n
537 537 s> Accept-Encoding: identity\r\n
538 538 s> user-agent: test\r\n
539 539 s> host: $LOCALIP:$HGPORT\r\n (glob)
540 540 s> \r\n
541 541 s> makefile('rb', None)
542 542 s> HTTP/1.1 200 Script output follows\r\n
543 543 s> Server: testing stub value\r\n
544 544 s> Date: $HTTP_DATE$\r\n
545 545 s> ETag: W/"*"\r\n (glob)
546 546 s> Content-Type: text/html; charset=ascii\r\n
547 547 s> Transfer-Encoding: chunked\r\n
548 548 s> \r\n
549 549 s> 414\r\n
550 550 s> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n
551 551 s> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">\n
552 552 s> <head>\n
553 553 s> <link rel="icon" href="/redirected/static/hgicon.png" type="image/png" />\n
554 554 s> <meta name="robots" content="index, nofollow" />\n
555 555 s> <link rel="stylesheet" href="/redirected/static/style-paper.css" type="text/css" />\n
556 556 s> <script type="text/javascript" src="/redirected/static/mercurial.js"></script>\n
557 557 s> \n
558 558 s> <title>redirected: log</title>\n
559 559 s> <link rel="alternate" type="application/atom+xml"\n
560 560 s> href="/redirected/atom-log" title="Atom feed for redirected" />\n
561 561 s> <link rel="alternate" type="application/rss+xml"\n
562 562 s> href="/redirected/rss-log" title="RSS feed for redirected" />\n
563 563 s> </head>\n
564 564 s> <body>\n
565 565 s> \n
566 566 s> <div class="container">\n
567 567 s> <div class="menu">\n
568 568 s> <div class="logo">\n
569 569 s> <a href="https://mercurial-scm.org/">\n
570 570 s> <img src="/redirected/static/hglogo.png" alt="mercurial" /></a>\n
571 571 s> </div>\n
572 572 s> <ul>\n
573 573 s> <li class="active">log</li>\n
574 574 s> <li><a href="/redirected/graph/tip">graph</a></li>\n
575 575 s> <li><a href="/redirected/tags">tags</a></li>\n
576 576 s> <li><a href="
577 577 s> \r\n
578 578 s> 810\r\n
579 579 s> /redirected/bookmarks">bookmarks</a></li>\n
580 580 s> <li><a href="/redirected/branches">branches</a></li>\n
581 581 s> </ul>\n
582 582 s> <ul>\n
583 583 s> <li><a href="/redirected/rev/tip">changeset</a></li>\n
584 584 s> <li><a href="/redirected/file/tip">browse</a></li>\n
585 585 s> </ul>\n
586 586 s> <ul>\n
587 587 s> \n
588 588 s> </ul>\n
589 589 s> <ul>\n
590 590 s> <li><a href="/redirected/help">help</a></li>\n
591 591 s> </ul>\n
592 592 s> <div class="atom-logo">\n
593 593 s> <a href="/redirected/atom-log" title="subscribe to atom feed">\n
594 594 s> <img class="atom-logo" src="/redirected/static/feed-icon-14x14.png" alt="atom feed" />\n
595 595 s> </a>\n
596 596 s> </div>\n
597 597 s> </div>\n
598 598 s> \n
599 599 s> <div class="main">\n
600 600 s> <h2 class="breadcrumb"><a href="/">Mercurial</a> &gt; <a href="/redirected">redirected</a> </h2>\n
601 601 s> <h3>log</h3>\n
602 602 s> \n
603 603 s> \n
604 604 s> <form class="search" action="/redirected/log">\n
605 605 s> \n
606 606 s> <p><input name="rev" id="search1" type="text" size="30" value="" /></p>\n
607 607 s> <div id="hint">Find changesets by keywords (author, files, the commit message), revision\n
608 608 s> number or hash, or <a href="/redirected/help/revsets">revset expression</a>.</div>\n
609 609 s> </form>\n
610 610 s> \n
611 611 s> <div class="navigate">\n
612 612 s> <a href="/redirected/shortlog/tip?revcount=30">less</a>\n
613 613 s> <a href="/redirected/shortlog/tip?revcount=120">more</a>\n
614 614 s> | rev 0: <a href="/redirected/shortlog/96ee1d7354c4">(0)</a> <a href="/redirected/shortlog/tip">tip</a> \n
615 615 s> </div>\n
616 616 s> \n
617 617 s> <table class="bigtable">\n
618 618 s> <thead>\n
619 619 s> <tr>\n
620 620 s> <th class="age">age</th>\n
621 621 s> <th class="author">author</th>\n
622 622 s> <th class="description">description</th>\n
623 623 s> </tr>\n
624 624 s> </thead>\n
625 625 s> <tbody class="stripes2">\n
626 626 s> <tr>\n
627 627 s> <td class="age">Thu, 01 Jan 1970 00:00:00 +0000</td>\n
628 628 s> <td class="author">test</td>\n
629 629 s> <td class="description">\n
630 630 s> <a href="/redirected/rev/96ee1d7354c4">initial</a>\n
631 631 s> <span class="phase">draft</span> <span class="branchhead">default</span> <span class="tag">tip</span> \n
632 632 s> </td>\n
633 633 s> </tr>\n
634 634 s> \n
635 635 s> </tbody>\n
636 636 s> </table>\n
637 637 s> \n
638 638 s> <div class="navigate">\n
639 639 s> <a href="/redirected/shortlog/tip?revcount=30">less</a>\n
640 640 s> <a href="/redirected/shortlog/tip?revcount=120">more</a>\n
641 641 s> | rev 0: <a href="/redirected/shortlog/96ee1d7354c4">(0)</a> <a href="/redirected/shortlog/tip">tip</a> \n
642 642 s> </div>\n
643 643 s> \n
644 644 s> <script type="text/javascript">\n
645 645 s> ajaxScrollInit(\n
646 646 s> \'/redirected/shortlog/%next%\',\n
647 647 s> \'\', <!-- NEXTHASH\n
648 648 s> function (htmlText) {
649 649 s> \r\n
650 650 s> 14a\r\n
651 651 s> \n
652 652 s> var m = htmlText.match(/\'(\\w+)\', <!-- NEXTHASH/);\n
653 653 s> return m ? m[1] : null;\n
654 654 s> },\n
655 655 s> \'.bigtable > tbody\',\n
656 656 s> \'<tr class="%class%">\\\n
657 657 s> <td colspan="3" style="text-align: center;">%text%</td>\\\n
658 658 s> </tr>\'\n
659 659 s> );\n
660 660 s> </script>\n
661 661 s> \n
662 662 s> </div>\n
663 663 s> </div>\n
664 664 s> \n
665 665 s> \n
666 666 s> \n
667 667 s> </body>\n
668 668 s> </html>\n
669 669 s> \n
670 670 s> \r\n
671 671 s> 0\r\n
672 672 s> \r\n
673 673
674 674 $ hg --verbose debugwireproto http://$LOCALIP:$HGPORT/redirector << EOF
675 675 > command heads
676 676 > EOF
677 677 s> setsockopt(6, 1, 1) -> None (py3 !)
678 678 s> GET /redirector?cmd=capabilities HTTP/1.1\r\n
679 679 s> Accept-Encoding: identity\r\n
680 680 s> accept: application/mercurial-0.1\r\n
681 681 s> host: $LOCALIP:$HGPORT\r\n (glob)
682 682 s> user-agent: Mercurial debugwireproto\r\n
683 683 s> \r\n
684 684 s> makefile('rb', None)
685 685 s> HTTP/1.1 301 Redirect\r\n
686 686 s> Server: testing stub value\r\n
687 687 s> Date: $HTTP_DATE$\r\n
688 688 s> Location: http://$LOCALIP:$HGPORT/redirected\r\n (glob)
689 689 s> Content-Type: text/plain\r\n
690 690 s> Content-Length: 10\r\n
691 691 s> \r\n
692 692 s> redirected
693 693 s> setsockopt(6, 1, 1) -> None (py3 !)
694 694 s> GET /redirected HTTP/1.1\r\n
695 695 s> Accept-Encoding: identity\r\n
696 696 s> accept: application/mercurial-0.1\r\n
697 697 s> host: $LOCALIP:$HGPORT\r\n (glob)
698 698 s> user-agent: Mercurial debugwireproto\r\n
699 699 s> \r\n
700 700 s> makefile('rb', None)
701 701 s> HTTP/1.1 200 Script output follows\r\n
702 702 s> Server: testing stub value\r\n
703 703 s> Date: $HTTP_DATE$\r\n
704 704 s> ETag: W/"*"\r\n (glob)
705 705 s> Content-Type: text/html; charset=ascii\r\n
706 706 s> Transfer-Encoding: chunked\r\n
707 707 s> \r\n
708 708 real URL is http://$LOCALIP:$HGPORT/redirected (glob)
709 709 s> 414\r\n
710 710 s> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n
711 711 s> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">\n
712 712 s> <head>\n
713 713 s> <link rel="icon" href="/redirected/static/hgicon.png" type="image/png" />\n
714 714 s> <meta name="robots" content="index, nofollow" />\n
715 715 s> <link rel="stylesheet" href="/redirected/static/style-paper.css" type="text/css" />\n
716 716 s> <script type="text/javascript" src="/redirected/static/mercurial.js"></script>\n
717 717 s> \n
718 718 s> <title>redirected: log</title>\n
719 719 s> <link rel="alternate" type="application/atom+xml"\n
720 720 s> href="/redirected/atom-log" title="Atom feed for redirected" />\n
721 721 s> <link rel="alternate" type="application/rss+xml"\n
722 722 s> href="/redirected/rss-log" title="RSS feed for redirected" />\n
723 723 s> </head>\n
724 724 s> <body>\n
725 725 s> \n
726 726 s> <div class="container">\n
727 727 s> <div class="menu">\n
728 728 s> <div class="logo">\n
729 729 s> <a href="https://mercurial-scm.org/">\n
730 730 s> <img src="/redirected/static/hglogo.png" alt="mercurial" /></a>\n
731 731 s> </div>\n
732 732 s> <ul>\n
733 733 s> <li class="active">log</li>\n
734 734 s> <li><a href="/redirected/graph/tip">graph</a></li>\n
735 735 s> <li><a href="/redirected/tags">tags</a
736 736 s> setsockopt(6, 1, 1) -> None (py3 !)
737 737 s> GET /redirected?cmd=capabilities HTTP/1.1\r\n
738 738 s> Accept-Encoding: identity\r\n
739 739 s> accept: application/mercurial-0.1\r\n
740 740 s> host: $LOCALIP:$HGPORT\r\n (glob)
741 741 s> user-agent: Mercurial debugwireproto\r\n
742 742 s> \r\n
743 743 s> makefile('rb', None)
744 744 s> HTTP/1.1 200 Script output follows\r\n
745 745 s> Server: testing stub value\r\n
746 746 s> Date: $HTTP_DATE$\r\n
747 747 s> Content-Type: application/mercurial-0.1\r\n
748 748 s> Content-Length: 480\r\n
749 749 s> \r\n
750 750 real URL is http://$LOCALIP:$HGPORT/redirected (glob)
751 751 s> batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
752 752 sending heads command
753 753 s> setsockopt(6, 1, 1) -> None (py3 !)
754 754 s> GET /redirected?cmd=heads HTTP/1.1\r\n
755 755 s> Accept-Encoding: identity\r\n
756 756 s> vary: X-HgProto-1\r\n
757 757 s> x-hgproto-1: 0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull\r\n
758 758 s> accept: application/mercurial-0.1\r\n
759 759 s> host: $LOCALIP:$HGPORT\r\n (glob)
760 760 s> user-agent: Mercurial debugwireproto\r\n
761 761 s> \r\n
762 762 s> makefile('rb', None)
763 763 s> HTTP/1.1 200 Script output follows\r\n
764 764 s> Server: testing stub value\r\n
765 765 s> Date: $HTTP_DATE$\r\n
766 766 s> Content-Type: application/mercurial-0.1\r\n
767 767 s> Content-Length: 41\r\n
768 768 s> \r\n
769 769 s> 96ee1d7354c4ad7372047672c36a1f561e3a6a4c\n
770 770 response: [
771 771 b'\x96\xee\x1dsT\xc4\xadsr\x04vr\xc3j\x1fV\x1e:jL'
772 772 ]
773 773 (sent 4 HTTP requests and * bytes; received * bytes in responses) (glob)
General Comments 0
You need to be logged in to leave comments. Login now