annotate tests/test-http-protocol.t @ 37725:3ea8323d6f95

wireprotov2: change command response protocol to include a leading map The error handling mechanism for the new wire protocol isn't very well-defined. This commit takes us a step in the right direction by introducing a leading CBOR map for command responses. This map will contain an overall result of the command. Currently, the map indicates whether the command was overall successful or if an error occurred. And if an error occurred, that error is present in the map. There is still a dedicated error frame. My intent is to use that for protocol-level errors and for errors that are encountered after the initial response frame has been sent. This will be clarified in a later commit. Differential Revision: https://phab.mercurial-scm.org/D3385
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 14 Apr 2018 15:19:36 -0700
parents deff7cf7eefd
children 143632f82479
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
37558
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
1 $ . $TESTDIR/wireprotohelpers.sh
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
2
30762
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
3 $ cat >> $HGRCPATH << EOF
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
4 > [web]
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
5 > push_ssl = false
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
6 > allow_push = *
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
7 > EOF
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
8
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
9 $ hg init server
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
10 $ cd server
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
11 $ touch a
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
12 $ hg -q commit -A -m initial
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
13 $ cd ..
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
14
34483
a6d95a8b7243 serve: make tests compatible with chg
Saurabh Singh <singhsrb@fb.com>
parents: 31028
diff changeset
15 $ hg serve -R server -p $HGPORT -d --pid-file hg.pid
30762
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
16 $ cat hg.pid >> $DAEMON_PIDS
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
17
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
18 compression formats are advertised in compression capability
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
19
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
20 #if zstd
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
21 $ get-with-headers.py $LOCALIP:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep '^compression=zstd,zlib$' > /dev/null
30762
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
22 #else
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
23 $ get-with-headers.py $LOCALIP:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep '^compression=zlib$' > /dev/null
30762
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
24 #endif
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
25
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
26 $ killdaemons.py
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
27
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
28 server.compressionengines can replace engines list wholesale
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
29
34483
a6d95a8b7243 serve: make tests compatible with chg
Saurabh Singh <singhsrb@fb.com>
parents: 31028
diff changeset
30 $ hg serve --config server.compressionengines=none -R server -p $HGPORT -d --pid-file hg.pid
30762
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
31 $ cat hg.pid > $DAEMON_PIDS
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
32 $ get-with-headers.py $LOCALIP:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep '^compression=none$' > /dev/null
30762
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
33
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
34 $ killdaemons.py
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
35
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
36 Order of engines can also change
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
37
34483
a6d95a8b7243 serve: make tests compatible with chg
Saurabh Singh <singhsrb@fb.com>
parents: 31028
diff changeset
38 $ hg serve --config server.compressionengines=none,zlib -R server -p $HGPORT -d --pid-file hg.pid
30762
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
39 $ cat hg.pid > $DAEMON_PIDS
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
40 $ get-with-headers.py $LOCALIP:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep '^compression=none,zlib$' > /dev/null
30762
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
41
35b516f800e0 wireproto: advertise supported media types and compression formats
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
42 $ killdaemons.py
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
43
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
44 Start a default server again
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
45
34483
a6d95a8b7243 serve: make tests compatible with chg
Saurabh Singh <singhsrb@fb.com>
parents: 31028
diff changeset
46 $ hg serve -R server -p $HGPORT -d --pid-file hg.pid
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
47 $ cat hg.pid > $DAEMON_PIDS
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
48
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
49 Server should send application/mercurial-0.1 to clients if no Accept is used
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
50
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
51 $ get-with-headers.py --headeronly $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' -
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
52 200 Script output follows
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
53 content-type: application/mercurial-0.1
37011
16203c6079e7 tests: use $HTTP_DATE$ for Date header
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34483
diff changeset
54 date: $HTTP_DATE$
37012
5890e5872f36 hgweb: allow defining Server response header for HTTP server
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37011
diff changeset
55 server: testing stub value
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
56 transfer-encoding: chunked
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
57
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
58 Server should send application/mercurial-0.1 when client says it wants it
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
59
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
60 $ get-with-headers.py --hgproto '0.1' --headeronly $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' -
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
61 200 Script output follows
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
62 content-type: application/mercurial-0.1
37011
16203c6079e7 tests: use $HTTP_DATE$ for Date header
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34483
diff changeset
63 date: $HTTP_DATE$
37012
5890e5872f36 hgweb: allow defining Server response header for HTTP server
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37011
diff changeset
64 server: testing stub value
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
65 transfer-encoding: chunked
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
66
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
67 Server should send application/mercurial-0.2 when client says it wants it
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
68
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
69 $ get-with-headers.py --hgproto '0.2' --headeronly $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' -
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
70 200 Script output follows
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
71 content-type: application/mercurial-0.2
37011
16203c6079e7 tests: use $HTTP_DATE$ for Date header
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34483
diff changeset
72 date: $HTTP_DATE$
37012
5890e5872f36 hgweb: allow defining Server response header for HTTP server
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37011
diff changeset
73 server: testing stub value
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
74 transfer-encoding: chunked
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
75
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
76 $ get-with-headers.py --hgproto '0.1 0.2' --headeronly $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' -
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
77 200 Script output follows
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
78 content-type: application/mercurial-0.2
37011
16203c6079e7 tests: use $HTTP_DATE$ for Date header
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34483
diff changeset
79 date: $HTTP_DATE$
37012
5890e5872f36 hgweb: allow defining Server response header for HTTP server
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37011
diff changeset
80 server: testing stub value
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
81 transfer-encoding: chunked
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
82
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
83 Requesting a compression format that server doesn't support results will fall back to 0.1
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
84
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
85 $ get-with-headers.py --hgproto '0.2 comp=aa' --headeronly $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' -
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
86 200 Script output follows
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
87 content-type: application/mercurial-0.1
37011
16203c6079e7 tests: use $HTTP_DATE$ for Date header
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34483
diff changeset
88 date: $HTTP_DATE$
37012
5890e5872f36 hgweb: allow defining Server response header for HTTP server
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37011
diff changeset
89 server: testing stub value
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
90 transfer-encoding: chunked
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
91
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
92 #if zstd
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
93 zstd is used if available
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
94
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
95 $ get-with-headers.py --hgproto '0.2 comp=zstd' $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' > resp
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
96 $ f --size --hexdump --bytes 36 --sha1 resp
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
97 resp: size=248, sha1=4d8d8f87fb82bd542ce52881fdc94f850748
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
98 0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
99 0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 04 7a 73 74 64 |t follows...zstd|
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
100 0020: 28 b5 2f fd |(./.|
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
101
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
102 #endif
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
103
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
104 application/mercurial-0.2 is not yet used on non-streaming responses
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
105
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
106 $ get-with-headers.py --hgproto '0.2' $LOCALIP:$HGPORT '?cmd=heads' -
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
107 200 Script output follows
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
108 content-length: 41
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
109 content-type: application/mercurial-0.1
37011
16203c6079e7 tests: use $HTTP_DATE$ for Date header
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34483
diff changeset
110 date: $HTTP_DATE$
37012
5890e5872f36 hgweb: allow defining Server response header for HTTP server
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37011
diff changeset
111 server: testing stub value
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
112
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
113 e93700bd72895c5addab234c56d4024b487a362f
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
114
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
115 Now test protocol preference usage
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
116
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
117 $ killdaemons.py
34483
a6d95a8b7243 serve: make tests compatible with chg
Saurabh Singh <singhsrb@fb.com>
parents: 31028
diff changeset
118 $ hg serve --config server.compressionengines=none,zlib -R server -p $HGPORT -d --pid-file hg.pid
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
119 $ cat hg.pid > $DAEMON_PIDS
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
120
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
121 No Accept will send 0.1+zlib, even though "none" is preferred b/c "none" isn't supported on 0.1
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
122
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
123 $ get-with-headers.py --headeronly $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' Content-Type
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
124 200 Script output follows
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
125 content-type: application/mercurial-0.1
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
126
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
127 $ get-with-headers.py $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' > resp
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
128 $ f --size --hexdump --bytes 28 --sha1 resp
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
129 resp: size=227, sha1=35a4c074da74f32f5440da3cbf04
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
130 0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
131 0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 78 |t follows..x|
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
132
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
133 Explicit 0.1 will send zlib because "none" isn't supported on 0.1
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
134
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
135 $ get-with-headers.py --hgproto '0.1' $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' > resp
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
136 $ f --size --hexdump --bytes 28 --sha1 resp
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
137 resp: size=227, sha1=35a4c074da74f32f5440da3cbf04
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
138 0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
139 0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 78 |t follows..x|
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
140
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
141 0.2 with no compression will get "none" because that is server's preference
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
142 (spec says ZL and UN are implicitly supported)
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
143
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
144 $ get-with-headers.py --hgproto '0.2' $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' > resp
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
145 $ f --size --hexdump --bytes 32 --sha1 resp
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
146 resp: size=432, sha1=ac931b412ec185a02e0e5bcff98dac83
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
147 0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
148 0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 04 6e 6f 6e 65 |t follows...none|
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
149
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
150 Client receives server preference even if local order doesn't match
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
151
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
152 $ get-with-headers.py --hgproto '0.2 comp=zlib,none' $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' > resp
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
153 $ f --size --hexdump --bytes 32 --sha1 resp
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
154 resp: size=432, sha1=ac931b412ec185a02e0e5bcff98dac83
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
155 0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
156 0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 04 6e 6f 6e 65 |t follows...none|
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
157
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
158 Client receives only supported format even if not server preferred format
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
159
31028
636cf3f7620d tests: use LOCALIP
Jun Wu <quark@fb.com>
parents: 30852
diff changeset
160 $ get-with-headers.py --hgproto '0.2 comp=zlib' $LOCALIP:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' > resp
30764
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
161 $ f --size --hexdump --bytes 33 --sha1 resp
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
162 resp: size=232, sha1=a1c727f0c9693ca15742a75c30419bc36
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
163 0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
164 0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 04 7a 6c 69 62 |t follows...zlib|
e75463e3179f protocol: send application/mercurial-0.2 responses to capable clients
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30762
diff changeset
165 0020: 78 |x|
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
166
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
167 $ killdaemons.py
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
168 $ cd ..
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
169
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
170 Test listkeys for listing namespaces
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
171
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
172 $ hg init empty
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
173 $ hg -R empty serve -p $HGPORT -d --pid-file hg.pid
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
174 $ cat hg.pid > $DAEMON_PIDS
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
175
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
176 $ hg --verbose debugwireproto http://$LOCALIP:$HGPORT << EOF
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
177 > command listkeys
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
178 > namespace namespaces
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
179 > EOF
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
180 s> GET /?cmd=capabilities HTTP/1.1\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
181 s> Accept-Encoding: identity\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
182 s> accept: application/mercurial-0.1\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
183 s> host: $LOCALIP:$HGPORT\r\n (glob)
37483
61e405fb6372 wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37413
diff changeset
184 s> user-agent: Mercurial debugwireproto\r\n
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
185 s> \r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
186 s> makefile('rb', None)
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
187 s> HTTP/1.1 200 Script output follows\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
188 s> Server: testing stub value\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
189 s> Date: $HTTP_DATE$\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
190 s> Content-Type: application/mercurial-0.1\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
191 s> Content-Length: *\r\n (glob)
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
192 s> \r\n
37413
33af46d639b4 wireproto: send server capabilities in canonical order
Joerg Sonnenberger <joerg@bec.de>
parents: 37322
diff changeset
193 s> batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
194 sending listkeys command
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
195 s> GET /?cmd=listkeys HTTP/1.1\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
196 s> Accept-Encoding: identity\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
197 s> vary: X-HgArg-1,X-HgProto-1\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
198 s> x-hgarg-1: namespace=namespaces\r\n
37498
aacfca6f9767 wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents: 37483
diff changeset
199 s> x-hgproto-1: 0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull\r\n
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
200 s> accept: application/mercurial-0.1\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
201 s> host: $LOCALIP:$HGPORT\r\n (glob)
37483
61e405fb6372 wireproto: crude support for version 2 HTTP peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37413
diff changeset
202 s> user-agent: Mercurial debugwireproto\r\n
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
203 s> \r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
204 s> makefile('rb', None)
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
205 s> HTTP/1.1 200 Script output follows\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
206 s> Server: testing stub value\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
207 s> Date: $HTTP_DATE$\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
208 s> Content-Type: application/mercurial-0.1\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
209 s> Content-Length: 30\r\n
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
210 s> \r\n
37322
a67fd1fe5109 stringutil: drop escapedata() in favor of escapestr()
Yuya Nishihara <yuya@tcha.org>
parents: 37300
diff changeset
211 s> bookmarks\t\n
a67fd1fe5109 stringutil: drop escapedata() in favor of escapestr()
Yuya Nishihara <yuya@tcha.org>
parents: 37300
diff changeset
212 s> namespaces\t\n
a67fd1fe5109 stringutil: drop escapedata() in favor of escapestr()
Yuya Nishihara <yuya@tcha.org>
parents: 37300
diff changeset
213 s> phases\t
37652
fe8c6f9f2914 debugcommands: use command executor for invoking commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37645
diff changeset
214 response: {b'bookmarks': b'', b'namespaces': b'', b'phases': b''}
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
215
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
216 Same thing, but with "httprequest" command
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
217
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
218 $ hg --verbose debugwireproto --peer raw http://$LOCALIP:$HGPORT << EOF
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
219 > httprequest GET ?cmd=listkeys
37048
a708e1e4d7a8 url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37047
diff changeset
220 > user-agent: test
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
221 > x-hgarg-1: namespace=namespaces
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
222 > EOF
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
223 using raw connection to peer
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
224 s> GET /?cmd=listkeys HTTP/1.1\r\n
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
225 s> Accept-Encoding: identity\r\n
37048
a708e1e4d7a8 url: support suppressing Accept header
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37047
diff changeset
226 s> user-agent: test\r\n
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
227 s> x-hgarg-1: namespace=namespaces\r\n
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
228 s> host: $LOCALIP:$HGPORT\r\n (glob)
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
229 s> \r\n
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
230 s> makefile('rb', None)
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
231 s> HTTP/1.1 200 Script output follows\r\n
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
232 s> Server: testing stub value\r\n
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
233 s> Date: $HTTP_DATE$\r\n
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
234 s> Content-Type: application/mercurial-0.1\r\n
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
235 s> Content-Length: 30\r\n
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
236 s> \r\n
37322
a67fd1fe5109 stringutil: drop escapedata() in favor of escapestr()
Yuya Nishihara <yuya@tcha.org>
parents: 37300
diff changeset
237 s> bookmarks\t\n
a67fd1fe5109 stringutil: drop escapedata() in favor of escapestr()
Yuya Nishihara <yuya@tcha.org>
parents: 37300
diff changeset
238 s> namespaces\t\n
a67fd1fe5109 stringutil: drop escapedata() in favor of escapestr()
Yuya Nishihara <yuya@tcha.org>
parents: 37300
diff changeset
239 s> phases\t
37016
b6a7070e7663 debugcommands: support sending HTTP requests with debugwireproto
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37015
diff changeset
240
37558
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
241 Client with HTTPv2 enabled advertises that and gets old capabilities response from old server
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
242
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
243 $ hg --config experimental.httppeer.advertise-v2=true --verbose debugwireproto http://$LOCALIP:$HGPORT << EOF
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
244 > command heads
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
245 > EOF
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
246 s> GET /?cmd=capabilities HTTP/1.1\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
247 s> Accept-Encoding: identity\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
248 s> vary: X-HgProto-1,X-HgUpgrade-1\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
249 s> x-hgproto-1: cbor\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
250 s> x-hgupgrade-1: exp-http-v2-0001\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
251 s> accept: application/mercurial-0.1\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
252 s> host: $LOCALIP:$HGPORT\r\n (glob)
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
253 s> user-agent: Mercurial debugwireproto\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
254 s> \r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
255 s> makefile('rb', None)
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
256 s> HTTP/1.1 200 Script output follows\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
257 s> Server: testing stub value\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
258 s> Date: $HTTP_DATE$\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
259 s> Content-Type: application/mercurial-0.1\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
260 s> Content-Length: 458\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
261 s> \r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
262 s> batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
263 sending heads command
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
264 s> GET /?cmd=heads HTTP/1.1\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
265 s> Accept-Encoding: identity\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
266 s> vary: X-HgProto-1\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
267 s> x-hgproto-1: 0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
268 s> accept: application/mercurial-0.1\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
269 s> host: $LOCALIP:$HGPORT\r\n (glob)
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
270 s> user-agent: Mercurial debugwireproto\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
271 s> \r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
272 s> makefile('rb', None)
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
273 s> HTTP/1.1 200 Script output follows\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
274 s> Server: testing stub value\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
275 s> Date: $HTTP_DATE$\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
276 s> Content-Type: application/mercurial-0.1\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
277 s> Content-Length: 41\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
278 s> \r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
279 s> 0000000000000000000000000000000000000000\n
37652
fe8c6f9f2914 debugcommands: use command executor for invoking commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37645
diff changeset
280 response: [b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00']
37558
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
281
37015
fc8939825632 debugcommands: support connecting to HTTP peers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37012
diff changeset
282 $ killdaemons.py
37558
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
283 $ enablehttpv2 empty
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
284 $ hg -R empty serve -p $HGPORT -d --pid-file hg.pid
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
285 $ cat hg.pid > $DAEMON_PIDS
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
286
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
287 Client with HTTPv2 enabled automatically upgrades if the server supports it
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
288
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
289 $ hg --config experimental.httppeer.advertise-v2=true --verbose debugwireproto http://$LOCALIP:$HGPORT << EOF
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
290 > command heads
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
291 > EOF
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
292 s> GET /?cmd=capabilities HTTP/1.1\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
293 s> Accept-Encoding: identity\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
294 s> vary: X-HgProto-1,X-HgUpgrade-1\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
295 s> x-hgproto-1: cbor\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
296 s> x-hgupgrade-1: exp-http-v2-0001\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
297 s> accept: application/mercurial-0.1\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
298 s> host: $LOCALIP:$HGPORT\r\n (glob)
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
299 s> user-agent: Mercurial debugwireproto\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
300 s> \r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
301 s> makefile('rb', None)
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
302 s> HTTP/1.1 200 OK\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
303 s> Server: testing stub value\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
304 s> Date: $HTTP_DATE$\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
305 s> Content-Type: application/mercurial-cbor\r\n
37645
72b0982cd509 debugcommands: perform handshake when obtaining httpv2 peer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37558
diff changeset
306 s> Content-Length: *\r\n (glob)
37558
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
307 s> \r\n
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
308 s> \xa3Dapis\xa1Pexp-http-v2-0001\xa4Hcommands\xa7Eheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyCnewCnewColdColdInamespaceBnsKpermissions\x81DpushHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullKcompression\x82\xa1DnameDzstd\xa1DnameDzlibNrawrepoformats\x82LgeneraldeltaHrevlogv1Qframingmediatypes\x81X&application/mercurial-exp-framing-0005GapibaseDapi/Nv1capabilitiesY\x01\xcabatch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
37558
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
309 sending heads command
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
310 s> POST /api/exp-http-v2-0001/ro/heads HTTP/1.1\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
311 s> Accept-Encoding: identity\r\n
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
312 s> accept: application/mercurial-exp-framing-0005\r\n
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
313 s> content-type: application/mercurial-exp-framing-0005\r\n
37558
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
314 s> content-length: 20\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
315 s> host: $LOCALIP:$HGPORT\r\n (glob)
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
316 s> user-agent: Mercurial debugwireproto\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
317 s> \r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
318 s> \x0c\x00\x00\x01\x00\x01\x01\x11\xa1DnameEheads
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
319 s> makefile('rb', None)
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
320 s> HTTP/1.1 200 OK\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
321 s> Server: testing stub value\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
322 s> Date: $HTTP_DATE$\r\n
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
323 s> Content-Type: application/mercurial-exp-framing-0005\r\n
37558
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
324 s> Transfer-Encoding: chunked\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
325 s> \r\n
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
326 s> 29\r\n
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
327 s> !\x00\x00\x01\x00\x02\x012
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
328 s> \xa1FstatusBok\x81T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
37558
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
329 s> \r\n
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
330 received frame(size=33; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
37558
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
331 s> 0\r\n
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
332 s> \r\n
37722
89a16704114c wireprotov2: define response data as CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37657
diff changeset
333 response: [b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00']
37558
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
334
8a73132214a3 httppeer: support protocol upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37556
diff changeset
335 $ killdaemons.py