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