Show More
@@ -1,247 +1,248 | |||
|
1 | 1 | $ . $TESTDIR/wireprotohelpers.sh |
|
2 | 2 | |
|
3 | 3 | $ hg init server |
|
4 | 4 | $ hg -R server serve -p $HGPORT -d --pid-file hg.pid -E error.log |
|
5 | 5 | $ cat hg.pid > $DAEMON_PIDS |
|
6 | 6 | |
|
7 | 7 | A normal capabilities request is serviced for version 1 |
|
8 | 8 | |
|
9 | 9 | $ sendhttpraw << EOF |
|
10 | 10 | > httprequest GET ?cmd=capabilities |
|
11 | 11 | > user-agent: test |
|
12 | 12 | > EOF |
|
13 | 13 | using raw connection to peer |
|
14 | 14 | s> GET /?cmd=capabilities HTTP/1.1\r\n |
|
15 | 15 | s> Accept-Encoding: identity\r\n |
|
16 | 16 | s> user-agent: test\r\n |
|
17 | 17 | s> host: $LOCALIP:$HGPORT\r\n (glob) |
|
18 | 18 | s> \r\n |
|
19 | 19 | s> makefile('rb', None) |
|
20 | 20 | s> HTTP/1.1 200 Script output follows\r\n |
|
21 | 21 | s> Server: testing stub value\r\n |
|
22 | 22 | s> Date: $HTTP_DATE$\r\n |
|
23 | 23 | s> Content-Type: application/mercurial-0.1\r\n |
|
24 | 24 | s> Content-Length: 458\r\n |
|
25 | 25 | s> \r\n |
|
26 | 26 | 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 |
|
27 | 27 | |
|
28 | 28 | A proper request without the API server enabled returns the legacy response |
|
29 | 29 | |
|
30 | 30 | $ sendhttpraw << EOF |
|
31 | 31 | > httprequest GET ?cmd=capabilities |
|
32 | 32 | > user-agent: test |
|
33 | 33 | > x-hgupgrade-1: foo |
|
34 | 34 | > x-hgproto-1: cbor |
|
35 | 35 | > EOF |
|
36 | 36 | using raw connection to peer |
|
37 | 37 | s> GET /?cmd=capabilities HTTP/1.1\r\n |
|
38 | 38 | s> Accept-Encoding: identity\r\n |
|
39 | 39 | s> user-agent: test\r\n |
|
40 | 40 | s> x-hgproto-1: cbor\r\n |
|
41 | 41 | s> x-hgupgrade-1: foo\r\n |
|
42 | 42 | s> host: $LOCALIP:$HGPORT\r\n (glob) |
|
43 | 43 | s> \r\n |
|
44 | 44 | s> makefile('rb', None) |
|
45 | 45 | s> HTTP/1.1 200 Script output follows\r\n |
|
46 | 46 | s> Server: testing stub value\r\n |
|
47 | 47 | s> Date: $HTTP_DATE$\r\n |
|
48 | 48 | s> Content-Type: application/mercurial-0.1\r\n |
|
49 | 49 | s> Content-Length: 458\r\n |
|
50 | 50 | s> \r\n |
|
51 | 51 | 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 |
|
52 | 52 | |
|
53 | 53 | Restart with just API server enabled. This enables serving the new format. |
|
54 | 54 | |
|
55 | 55 | $ killdaemons.py |
|
56 | 56 | $ cat error.log |
|
57 | 57 | |
|
58 | 58 | $ cat >> server/.hg/hgrc << EOF |
|
59 | 59 | > [experimental] |
|
60 | 60 | > web.apiserver = true |
|
61 | 61 | > EOF |
|
62 | 62 | |
|
63 | 63 | $ hg -R server serve -p $HGPORT -d --pid-file hg.pid -E error.log |
|
64 | 64 | $ cat hg.pid > $DAEMON_PIDS |
|
65 | 65 | |
|
66 | 66 | X-HgUpgrade-<N> without CBOR advertisement uses legacy response |
|
67 | 67 | |
|
68 | 68 | $ sendhttpraw << EOF |
|
69 | 69 | > httprequest GET ?cmd=capabilities |
|
70 | 70 | > user-agent: test |
|
71 | 71 | > x-hgupgrade-1: foo bar |
|
72 | 72 | > EOF |
|
73 | 73 | using raw connection to peer |
|
74 | 74 | s> GET /?cmd=capabilities HTTP/1.1\r\n |
|
75 | 75 | s> Accept-Encoding: identity\r\n |
|
76 | 76 | s> user-agent: test\r\n |
|
77 | 77 | s> x-hgupgrade-1: foo bar\r\n |
|
78 | 78 | s> host: $LOCALIP:$HGPORT\r\n (glob) |
|
79 | 79 | s> \r\n |
|
80 | 80 | s> makefile('rb', None) |
|
81 | 81 | s> HTTP/1.1 200 Script output follows\r\n |
|
82 | 82 | s> Server: testing stub value\r\n |
|
83 | 83 | s> Date: $HTTP_DATE$\r\n |
|
84 | 84 | s> Content-Type: application/mercurial-0.1\r\n |
|
85 | 85 | s> Content-Length: 458\r\n |
|
86 | 86 | s> \r\n |
|
87 | 87 | 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 |
|
88 | 88 | |
|
89 | 89 | X-HgUpgrade-<N> without known serialization in X-HgProto-<N> uses legacy response |
|
90 | 90 | |
|
91 | 91 | $ sendhttpraw << EOF |
|
92 | 92 | > httprequest GET ?cmd=capabilities |
|
93 | 93 | > user-agent: test |
|
94 | 94 | > x-hgupgrade-1: foo bar |
|
95 | 95 | > x-hgproto-1: some value |
|
96 | 96 | > EOF |
|
97 | 97 | using raw connection to peer |
|
98 | 98 | s> GET /?cmd=capabilities HTTP/1.1\r\n |
|
99 | 99 | s> Accept-Encoding: identity\r\n |
|
100 | 100 | s> user-agent: test\r\n |
|
101 | 101 | s> x-hgproto-1: some value\r\n |
|
102 | 102 | s> x-hgupgrade-1: foo bar\r\n |
|
103 | 103 | s> host: $LOCALIP:$HGPORT\r\n (glob) |
|
104 | 104 | s> \r\n |
|
105 | 105 | s> makefile('rb', None) |
|
106 | 106 | s> HTTP/1.1 200 Script output follows\r\n |
|
107 | 107 | s> Server: testing stub value\r\n |
|
108 | 108 | s> Date: $HTTP_DATE$\r\n |
|
109 | 109 | s> Content-Type: application/mercurial-0.1\r\n |
|
110 | 110 | s> Content-Length: 458\r\n |
|
111 | 111 | s> \r\n |
|
112 | 112 | 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 |
|
113 | 113 | |
|
114 | 114 | X-HgUpgrade-<N> + X-HgProto-<N> headers trigger new response format |
|
115 | 115 | |
|
116 | 116 | $ sendhttpraw << EOF |
|
117 | 117 | > httprequest GET ?cmd=capabilities |
|
118 | 118 | > user-agent: test |
|
119 | 119 | > x-hgupgrade-1: foo bar |
|
120 | 120 | > x-hgproto-1: cbor |
|
121 | 121 | > EOF |
|
122 | 122 | using raw connection to peer |
|
123 | 123 | s> GET /?cmd=capabilities HTTP/1.1\r\n |
|
124 | 124 | s> Accept-Encoding: identity\r\n |
|
125 | 125 | s> user-agent: test\r\n |
|
126 | 126 | s> x-hgproto-1: cbor\r\n |
|
127 | 127 | s> x-hgupgrade-1: foo bar\r\n |
|
128 | 128 | s> host: $LOCALIP:$HGPORT\r\n (glob) |
|
129 | 129 | s> \r\n |
|
130 | 130 | s> makefile('rb', None) |
|
131 | 131 | s> HTTP/1.1 200 OK\r\n |
|
132 | 132 | s> Server: testing stub value\r\n |
|
133 | 133 | s> Date: $HTTP_DATE$\r\n |
|
134 | 134 | s> Content-Type: application/mercurial-cbor\r\n |
|
135 | 135 | s> Content-Length: 496\r\n |
|
136 | 136 | s> \r\n |
|
137 | 137 | s> \xa3Dapis\xa0GapibaseDapi/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 |
|
138 | 138 | cbor> {b'apibase': b'api/', b'apis': {}, b'v1capabilities': b'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'} |
|
139 | 139 | |
|
140 | 140 | Restart server to enable HTTPv2 |
|
141 | 141 | |
|
142 | 142 | $ killdaemons.py |
|
143 | 143 | $ enablehttpv2 server |
|
144 | 144 | $ hg -R server serve -p $HGPORT -d --pid-file hg.pid -E error.log |
|
145 | $ cat hg.pid > $DAEMON_PIDS | |
|
145 | 146 | |
|
146 | 147 | Only requested API services are returned |
|
147 | 148 | |
|
148 | 149 | $ sendhttpraw << EOF |
|
149 | 150 | > httprequest GET ?cmd=capabilities |
|
150 | 151 | > user-agent: test |
|
151 | 152 | > x-hgupgrade-1: foo bar |
|
152 | 153 | > x-hgproto-1: cbor |
|
153 | 154 | > EOF |
|
154 | 155 | using raw connection to peer |
|
155 | 156 | s> GET /?cmd=capabilities HTTP/1.1\r\n |
|
156 | 157 | s> Accept-Encoding: identity\r\n |
|
157 | 158 | s> user-agent: test\r\n |
|
158 | 159 | s> x-hgproto-1: cbor\r\n |
|
159 | 160 | s> x-hgupgrade-1: foo bar\r\n |
|
160 | 161 | s> host: $LOCALIP:$HGPORT\r\n (glob) |
|
161 | 162 | s> \r\n |
|
162 | 163 | s> makefile('rb', None) |
|
163 | 164 | s> HTTP/1.1 200 OK\r\n |
|
164 | 165 | s> Server: testing stub value\r\n |
|
165 | 166 | s> Date: $HTTP_DATE$\r\n |
|
166 | 167 | s> Content-Type: application/mercurial-cbor\r\n |
|
167 | 168 | s> Content-Length: 496\r\n |
|
168 | 169 | s> \r\n |
|
169 | 170 | s> \xa3Dapis\xa0GapibaseDapi/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 |
|
170 | 171 | cbor> {b'apibase': b'api/', b'apis': {}, b'v1capabilities': b'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'} |
|
171 | 172 | |
|
172 | 173 | Request for HTTPv2 service returns information about it |
|
173 | 174 | |
|
174 | 175 | $ sendhttpraw << EOF |
|
175 | 176 | > httprequest GET ?cmd=capabilities |
|
176 | 177 | > user-agent: test |
|
177 | 178 | > x-hgupgrade-1: exp-http-v2-0001 foo bar |
|
178 | 179 | > x-hgproto-1: cbor |
|
179 | 180 | > EOF |
|
180 | 181 | using raw connection to peer |
|
181 | 182 | s> GET /?cmd=capabilities HTTP/1.1\r\n |
|
182 | 183 | s> Accept-Encoding: identity\r\n |
|
183 | 184 | s> user-agent: test\r\n |
|
184 | 185 | s> x-hgproto-1: cbor\r\n |
|
185 | 186 | s> x-hgupgrade-1: exp-http-v2-0001 foo bar\r\n |
|
186 | 187 | s> host: $LOCALIP:$HGPORT\r\n (glob) |
|
187 | 188 | s> \r\n |
|
188 | 189 | s> makefile('rb', None) |
|
189 | 190 | s> HTTP/1.1 200 OK\r\n |
|
190 | 191 | s> Server: testing stub value\r\n |
|
191 | 192 | s> Date: $HTTP_DATE$\r\n |
|
192 | 193 | s> Content-Type: application/mercurial-cbor\r\n |
|
193 | 194 | s> Content-Length: *\r\n (glob) |
|
194 | 195 | s> \r\n |
|
195 | 196 | 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 |
|
196 | 197 | cbor> {b'apibase': b'api/', b'apis': {b'exp-http-v2-0001': {b'commands': {b'branchmap': {b'args': {}, b'permissions': [b'pull']}, b'capabilities': {b'args': {}, b'permissions': [b'pull']}, b'heads': {b'args': {b'publiconly': False}, b'permissions': [b'pull']}, b'known': {b'args': {b'nodes': [b'deadbeef']}, b'permissions': [b'pull']}, b'listkeys': {b'args': {b'namespace': b'ns'}, b'permissions': [b'pull']}, b'lookup': {b'args': {b'key': b'foo'}, b'permissions': [b'pull']}, b'pushkey': {b'args': {b'key': b'key', b'namespace': b'ns', b'new': b'new', b'old': b'old'}, b'permissions': [b'push']}}, b'compression': [{b'name': b'zstd'}, {b'name': b'zlib'}], b'framingmediatypes': [b'application/mercurial-exp-framing-0005'], b'rawrepoformats': [b'generaldelta', b'revlogv1']}}, b'v1capabilities': b'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'} |
|
197 | 198 | |
|
198 | 199 | capabilities command returns expected info |
|
199 | 200 | |
|
200 | 201 | $ sendhttpv2peerhandshake << EOF |
|
201 | 202 | > command capabilities |
|
202 | 203 | > EOF |
|
203 | 204 | creating http peer for wire protocol version 2 |
|
204 | 205 | s> GET /?cmd=capabilities HTTP/1.1\r\n |
|
205 | 206 | s> Accept-Encoding: identity\r\n |
|
206 | 207 | s> vary: X-HgProto-1,X-HgUpgrade-1\r\n |
|
207 | 208 | s> x-hgproto-1: cbor\r\n |
|
208 | 209 | s> x-hgupgrade-1: exp-http-v2-0001\r\n |
|
209 | 210 | s> accept: application/mercurial-0.1\r\n |
|
210 | 211 | s> host: $LOCALIP:$HGPORT\r\n (glob) |
|
211 | 212 | s> user-agent: Mercurial debugwireproto\r\n |
|
212 | 213 | s> \r\n |
|
213 | 214 | s> makefile('rb', None) |
|
214 | 215 | s> HTTP/1.1 200 OK\r\n |
|
215 | 216 | s> Server: testing stub value\r\n |
|
216 | 217 | s> Date: $HTTP_DATE$\r\n |
|
217 | 218 | s> Content-Type: application/mercurial-cbor\r\n |
|
218 | 219 | s> Content-Length: *\r\n (glob) |
|
219 | 220 | s> \r\n |
|
220 | 221 | 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 |
|
221 | 222 | sending capabilities command |
|
222 | 223 | s> POST /api/exp-http-v2-0001/ro/capabilities HTTP/1.1\r\n |
|
223 | 224 | s> Accept-Encoding: identity\r\n |
|
224 | 225 | s> *\r\n (glob) |
|
225 | 226 | s> content-type: application/mercurial-exp-framing-0005\r\n |
|
226 | 227 | s> content-length: 27\r\n |
|
227 | 228 | s> host: $LOCALIP:$HGPORT\r\n (glob) |
|
228 | 229 | s> user-agent: Mercurial debugwireproto\r\n |
|
229 | 230 | s> \r\n |
|
230 | 231 | s> \x13\x00\x00\x01\x00\x01\x01\x11\xa1DnameLcapabilities |
|
231 | 232 | s> makefile('rb', None) |
|
232 | 233 | s> HTTP/1.1 200 OK\r\n |
|
233 | 234 | s> Server: testing stub value\r\n |
|
234 | 235 | s> Date: $HTTP_DATE$\r\n |
|
235 | 236 | s> Content-Type: application/mercurial-exp-framing-0005\r\n |
|
236 | 237 | s> Transfer-Encoding: chunked\r\n |
|
237 | 238 | s> \r\n |
|
238 | 239 | s> 1e2\r\n |
|
239 | 240 | s> \xda\x01\x00\x01\x00\x02\x012 |
|
240 | 241 | s> \xa1FstatusBok\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-0005 |
|
241 | 242 | s> \r\n |
|
242 | 243 | received frame(size=474; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos) |
|
243 | 244 | s> 0\r\n |
|
244 | 245 | s> \r\n |
|
245 | 246 | response: [{b'status': b'ok'}, {b'commands': {b'branchmap': {b'args': {}, b'permissions': [b'pull']}, b'capabilities': {b'args': {}, b'permissions': [b'pull']}, b'heads': {b'args': {b'publiconly': False}, b'permissions': [b'pull']}, b'known': {b'args': {b'nodes': [b'deadbeef']}, b'permissions': [b'pull']}, b'listkeys': {b'args': {b'namespace': b'ns'}, b'permissions': [b'pull']}, b'lookup': {b'args': {b'key': b'foo'}, b'permissions': [b'pull']}, b'pushkey': {b'args': {b'key': b'key', b'namespace': b'ns', b'new': b'new', b'old': b'old'}, b'permissions': [b'push']}}, b'compression': [{b'name': b'zstd'}, {b'name': b'zlib'}], b'framingmediatypes': [b'application/mercurial-exp-framing-0005'], b'rawrepoformats': [b'generaldelta', b'revlogv1']}] |
|
246 | 247 | |
|
247 | 248 | $ cat error.log |
General Comments 0
You need to be logged in to leave comments.
Login now