Mercurial > public > mercurial-scm > hg
diff tests/test-http-api-httpv2.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 | 538e850ae737 |
line wrap: on
line diff
--- a/tests/test-http-api-httpv2.t Sat Apr 14 14:37:23 2018 -0700 +++ b/tests/test-http-api-httpv2.t Sat Apr 14 15:19:36 2018 -0700 @@ -98,7 +98,7 @@ s> Content-Type: text/plain\r\n s> Content-Length: 85\r\n s> \r\n - s> client MUST specify Accept header with value: application/mercurial-exp-framing-0004\n + s> client MUST specify Accept header with value: application/mercurial-exp-framing-0005\n Bad Accept header results in 406 @@ -121,7 +121,7 @@ s> Content-Type: text/plain\r\n s> Content-Length: 85\r\n s> \r\n - s> client MUST specify Accept header with value: application/mercurial-exp-framing-0004\n + s> client MUST specify Accept header with value: application/mercurial-exp-framing-0005\n Bad Content-Type header results in 415 @@ -134,7 +134,7 @@ using raw connection to peer s> POST /api/exp-http-v2-0001/ro/customreadonly HTTP/1.1\r\n s> Accept-Encoding: identity\r\n - s> accept: application/mercurial-exp-framing-0004\r\n + s> accept: application/mercurial-exp-framing-0005\r\n s> content-type: badmedia\r\n s> user-agent: test\r\n s> host: $LOCALIP:$HGPORT\r\n (glob) @@ -146,7 +146,7 @@ s> Content-Type: text/plain\r\n s> Content-Length: 88\r\n s> \r\n - s> client MUST send Content-Type header with value: application/mercurial-exp-framing-0004\n + s> client MUST send Content-Type header with value: application/mercurial-exp-framing-0005\n Request to read-only command works out of the box @@ -161,7 +161,7 @@ s> POST /api/exp-http-v2-0001/ro/customreadonly HTTP/1.1\r\n s> Accept-Encoding: identity\r\n s> *\r\n (glob) - s> content-type: application/mercurial-exp-framing-0004\r\n + s> content-type: application/mercurial-exp-framing-0005\r\n s> user-agent: test\r\n s> content-length: 29\r\n s> host: $LOCALIP:$HGPORT\r\n (glob) @@ -171,11 +171,11 @@ s> HTTP/1.1 200 OK\r\n s> Server: testing stub value\r\n s> Date: $HTTP_DATE$\r\n - s> Content-Type: application/mercurial-exp-framing-0004\r\n + s> Content-Type: application/mercurial-exp-framing-0005\r\n s> Transfer-Encoding: chunked\r\n s> \r\n - s> 27\r\n - s> \x1f\x00\x00\x01\x00\x02\x012X\x1dcustomreadonly bytes response + s> 32\r\n + s> *\x00\x00\x01\x00\x02\x012\xa1FstatusBokX\x1dcustomreadonly bytes response s> \r\n s> 0\r\n s> \r\n @@ -187,8 +187,8 @@ sending customreadonly command s> POST /api/exp-http-v2-0001/ro/customreadonly HTTP/1.1\r\n s> Accept-Encoding: identity\r\n - s> accept: application/mercurial-exp-framing-0004\r\n - s> content-type: application/mercurial-exp-framing-0004\r\n + s> accept: application/mercurial-exp-framing-0005\r\n + s> content-type: application/mercurial-exp-framing-0005\r\n s> content-length: 29\r\n s> host: $LOCALIP:$HGPORT\r\n (glob) s> user-agent: Mercurial debugwireproto\r\n @@ -198,17 +198,17 @@ s> HTTP/1.1 200 OK\r\n s> Server: testing stub value\r\n s> Date: $HTTP_DATE$\r\n - s> Content-Type: application/mercurial-exp-framing-0004\r\n + s> Content-Type: application/mercurial-exp-framing-0005\r\n s> Transfer-Encoding: chunked\r\n s> \r\n - s> 27\r\n - s> \x1f\x00\x00\x01\x00\x02\x012 - s> X\x1dcustomreadonly bytes response + s> 32\r\n + s> *\x00\x00\x01\x00\x02\x012 + s> \xa1FstatusBokX\x1dcustomreadonly bytes response s> \r\n - received frame(size=31; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos) + received frame(size=42; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos) s> 0\r\n s> \r\n - response: [b'customreadonly bytes response'] + response: [{b'status': b'ok'}, b'customreadonly bytes response'] Request to read-write command fails because server is read-only by default @@ -301,8 +301,8 @@ using raw connection to peer s> POST /api/exp-http-v2-0001/rw/customreadonly HTTP/1.1\r\n s> Accept-Encoding: identity\r\n - s> accept: application/mercurial-exp-framing-0004\r\n - s> content-type: application/mercurial-exp-framing-0004\r\n + s> accept: application/mercurial-exp-framing-0005\r\n + s> content-type: application/mercurial-exp-framing-0005\r\n s> user-agent: test\r\n s> content-length: 29\r\n s> host: $LOCALIP:$HGPORT\r\n (glob) @@ -312,11 +312,11 @@ s> HTTP/1.1 200 OK\r\n s> Server: testing stub value\r\n s> Date: $HTTP_DATE$\r\n - s> Content-Type: application/mercurial-exp-framing-0004\r\n + s> Content-Type: application/mercurial-exp-framing-0005\r\n s> Transfer-Encoding: chunked\r\n s> \r\n - s> 27\r\n - s> \x1f\x00\x00\x01\x00\x02\x012X\x1dcustomreadonly bytes response + s> 32\r\n + s> *\x00\x00\x01\x00\x02\x012\xa1FstatusBokX\x1dcustomreadonly bytes response s> \r\n s> 0\r\n s> \r\n @@ -331,7 +331,7 @@ using raw connection to peer s> POST /api/exp-http-v2-0001/rw/badcommand HTTP/1.1\r\n s> Accept-Encoding: identity\r\n - s> accept: application/mercurial-exp-framing-0004\r\n + s> accept: application/mercurial-exp-framing-0005\r\n s> user-agent: test\r\n s> host: $LOCALIP:$HGPORT\r\n (glob) s> \r\n @@ -393,8 +393,8 @@ using raw connection to peer s> POST /api/exp-http-v2-0001/ro/debugreflect HTTP/1.1\r\n s> Accept-Encoding: identity\r\n - s> accept: application/mercurial-exp-framing-0004\r\n - s> content-type: application/mercurial-exp-framing-0004\r\n + s> accept: application/mercurial-exp-framing-0005\r\n + s> content-type: application/mercurial-exp-framing-0005\r\n s> user-agent: test\r\n s> content-length: 47\r\n s> host: $LOCALIP:$HGPORT\r\n (glob) @@ -424,8 +424,8 @@ using raw connection to peer s> POST /api/exp-http-v2-0001/ro/customreadonly HTTP/1.1\r\n s> Accept-Encoding: identity\r\n - s> accept: application/mercurial-exp-framing-0004\r\n - s> content-type: application/mercurial-exp-framing-0004\r\n + s> accept: application/mercurial-exp-framing-0005\r\n + s> content-type: application/mercurial-exp-framing-0005\r\n s> user-agent: test\r\n s> content-length: 29\r\n s> host: $LOCALIP:$HGPORT\r\n (glob) @@ -435,11 +435,11 @@ s> HTTP/1.1 200 OK\r\n s> Server: testing stub value\r\n s> Date: $HTTP_DATE$\r\n - s> Content-Type: application/mercurial-exp-framing-0004\r\n + s> Content-Type: application/mercurial-exp-framing-0005\r\n s> Transfer-Encoding: chunked\r\n s> \r\n - s> 27\r\n - s> \x1f\x00\x00\x01\x00\x02\x012X\x1dcustomreadonly bytes response + s> 32\r\n + s> *\x00\x00\x01\x00\x02\x012\xa1FstatusBokX\x1dcustomreadonly bytes response s> \r\n s> 0\r\n s> \r\n @@ -468,14 +468,14 @@ s> HTTP/1.1 200 OK\r\n s> Server: testing stub value\r\n s> Date: $HTTP_DATE$\r\n - s> Content-Type: application/mercurial-exp-framing-0004\r\n + s> Content-Type: application/mercurial-exp-framing-0005\r\n s> Transfer-Encoding: chunked\r\n s> \r\n - s> 27\r\n - s> \x1f\x00\x00\x01\x00\x02\x012X\x1dcustomreadonly bytes response + s> 32\r\n + s> *\x00\x00\x01\x00\x02\x012\xa1FstatusBokX\x1dcustomreadonly bytes response s> \r\n - s> 27\r\n - s> \x1f\x00\x00\x03\x00\x02\x002X\x1dcustomreadonly bytes response + s> 32\r\n + s> *\x00\x00\x03\x00\x02\x002\xa1FstatusBokX\x1dcustomreadonly bytes response s> \r\n s> 0\r\n s> \r\n @@ -495,8 +495,8 @@ using raw connection to peer s> POST /api/exp-http-v2-0001/ro/multirequest HTTP/1.1\r\n s> Accept-Encoding: identity\r\n - s> accept: application/mercurial-exp-framing-0004\r\n - s> content-type: application/mercurial-exp-framing-0004\r\n + s> accept: application/mercurial-exp-framing-0005\r\n + s> content-type: application/mercurial-exp-framing-0005\r\n s> user-agent: test\r\n s> content-length: 115\r\n s> host: $LOCALIP:$HGPORT\r\n (glob) @@ -506,14 +506,14 @@ s> HTTP/1.1 200 OK\r\n s> Server: testing stub value\r\n s> Date: $HTTP_DATE$\r\n - s> Content-Type: application/mercurial-exp-framing-0004\r\n + s> Content-Type: application/mercurial-exp-framing-0005\r\n s> Transfer-Encoding: chunked\r\n s> \r\n - s> 28\r\n - s> \x00\x00\x03\x00\x02\x012\xa3Fphases@Ibookmarks@Jnamespaces@ + s> 33\r\n + s> +\x00\x00\x03\x00\x02\x012\xa1FstatusBok\xa3Fphases@Ibookmarks@Jnamespaces@ s> \r\n - s> 9\r\n - s> \x01\x00\x00\x01\x00\x02\x002\xa0 + s> 14\r\n + s> \x0c\x00\x00\x01\x00\x02\x002\xa1FstatusBok\xa0 s> \r\n s> 0\r\n s> \r\n @@ -545,8 +545,8 @@ using raw connection to peer s> POST /api/exp-http-v2-0001/ro/multirequest HTTP/1.1\r\n s> Accept-Encoding: identity\r\n - s> accept: application/mercurial-exp-framing-0004\r\n - s> content-type: application/mercurial-exp-framing-0004\r\n + s> accept: application/mercurial-exp-framing-0005\r\n + s> content-type: application/mercurial-exp-framing-0005\r\n s> user-agent: test\r\n s> content-length: 22\r\n s> host: $LOCALIP:$HGPORT\r\n (glob)