Mercurial > hg
comparison tests/test-http-api.t @ 39814:d059cb669632
wireprotov2: allow multiple fields to follow revision maps
The *data wire protocol commands emit a series of CBOR values.
Because revision/delta data may be large, their data is emitted
outside the map as a top-level bytestring value.
Before this commit, we'd emit a single optional bytestring
value after the revision descriptor map. This got the job done.
But it was limiting in that we could only send a single field.
And, it required the consumer to know that the presence of a
key in the map implied the existence of a following bytestring
value.
This commit changes the encoding strategy so top-level bytestring
values in the stream are explicitly denoted in a "fieldsfollowing"
key. This key contains an array defining what fields that follow
and the expected size of each field.
By defining things this way, we can easily send N bytestring
values without any ambiguity about their order. In addition,
clients only need to know how to parse ``fieldsfollowing`` to
know if extra values are present.
Because this breaks backwards compatibility, we've bumped the version
number of the wire protocol version 2 API endpoint.
Differential Revision: https://phab.mercurial-scm.org/D4620
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 20 Sep 2018 12:57:23 -0700 |
parents | 538e850ae737 |
children | 41263df08109 |
comparison
equal
deleted
inserted
replaced
39813:c30faea8d02d | 39814:d059cb669632 |
---|---|
216 s> Known APIs: | 216 s> Known APIs: |
217 | 217 |
218 Accessing a known but not enabled API yields a different error | 218 Accessing a known but not enabled API yields a different error |
219 | 219 |
220 $ send << EOF | 220 $ send << EOF |
221 > httprequest GET api/exp-http-v2-0001 | 221 > httprequest GET api/exp-http-v2-0002 |
222 > user-agent: test | 222 > user-agent: test |
223 > EOF | 223 > EOF |
224 using raw connection to peer | 224 using raw connection to peer |
225 s> GET /api/exp-http-v2-0001 HTTP/1.1\r\n | 225 s> GET /api/exp-http-v2-0002 HTTP/1.1\r\n |
226 s> Accept-Encoding: identity\r\n | 226 s> Accept-Encoding: identity\r\n |
227 s> user-agent: test\r\n | 227 s> user-agent: test\r\n |
228 s> host: $LOCALIP:$HGPORT\r\n (glob) | 228 s> host: $LOCALIP:$HGPORT\r\n (glob) |
229 s> \r\n | 229 s> \r\n |
230 s> makefile('rb', None) | 230 s> makefile('rb', None) |
232 s> Server: testing stub value\r\n | 232 s> Server: testing stub value\r\n |
233 s> Date: $HTTP_DATE$\r\n | 233 s> Date: $HTTP_DATE$\r\n |
234 s> Content-Type: text/plain\r\n | 234 s> Content-Type: text/plain\r\n |
235 s> Content-Length: 33\r\n | 235 s> Content-Length: 33\r\n |
236 s> \r\n | 236 s> \r\n |
237 s> API exp-http-v2-0001 not enabled\n | 237 s> API exp-http-v2-0002 not enabled\n |
238 | 238 |
239 Restart server with support for HTTP v2 API | 239 Restart server with support for HTTP v2 API |
240 | 240 |
241 $ killdaemons.py | 241 $ killdaemons.py |
242 $ cat > server/.hg/hgrc << EOF | 242 $ cat > server/.hg/hgrc << EOF |
267 s> Content-Type: text/plain\r\n | 267 s> Content-Type: text/plain\r\n |
268 s> Content-Length: 96\r\n | 268 s> Content-Length: 96\r\n |
269 s> \r\n | 269 s> \r\n |
270 s> APIs can be accessed at /api/<name>, where <name> can be one of the following:\n | 270 s> APIs can be accessed at /api/<name>, where <name> can be one of the following:\n |
271 s> \n | 271 s> \n |
272 s> exp-http-v2-0001 | 272 s> exp-http-v2-0002 |
273 | 273 |
274 $ send << EOF | 274 $ send << EOF |
275 > httprequest GET api/ | 275 > httprequest GET api/ |
276 > user-agent: test | 276 > user-agent: test |
277 > EOF | 277 > EOF |
288 s> Content-Type: text/plain\r\n | 288 s> Content-Type: text/plain\r\n |
289 s> Content-Length: 96\r\n | 289 s> Content-Length: 96\r\n |
290 s> \r\n | 290 s> \r\n |
291 s> APIs can be accessed at /api/<name>, where <name> can be one of the following:\n | 291 s> APIs can be accessed at /api/<name>, where <name> can be one of the following:\n |
292 s> \n | 292 s> \n |
293 s> exp-http-v2-0001 | 293 s> exp-http-v2-0002 |