Mercurial > public > mercurial-scm > hg
diff tests/test-http-api-httpv2.t @ 37722:89a16704114c
wireprotov2: define response data as CBOR
Previously, response data was defined as a stream of bytes. We had
the option to declare it as CBOR using a frame flag.
We've converged all wire protocol commands exposed on version 2 to
CBOR. I think consistency is important. The overhead to encoding
things with CBOR is minimal. Even a very large bytestring can be
efficiently encoded using an indefinite length bytestring. Now,
there are limitations with consumers not being able to efficiently
stream large CBOR values. But these feel like solvable problems.
This commit removes the "is CBOR" frame flag from command response
frames and defines the frame as always consisting of a stream of
CBOR values.
The framing protocol media type has been bumped to reflect this
BC change.
Differential Revision: https://phab.mercurial-scm.org/D3382
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 14 Apr 2018 12:07:31 -0700 |
parents | ad1c07008e0b |
children | deff7cf7eefd |
line wrap: on
line diff
--- a/tests/test-http-api-httpv2.t Sat Apr 14 11:49:06 2018 -0700 +++ b/tests/test-http-api-httpv2.t Sat Apr 14 12:07:31 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-0003\n + s> client MUST specify Accept header with value: application/mercurial-exp-framing-0004\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-0003\n + s> client MUST specify Accept header with value: application/mercurial-exp-framing-0004\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-0003\r\n + s> accept: application/mercurial-exp-framing-0004\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-0003\n + s> client MUST send Content-Type header with value: application/mercurial-exp-framing-0004\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-0003\r\n + s> content-type: application/mercurial-exp-framing-0004\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-0003\r\n + s> Content-Type: application/mercurial-exp-framing-0004\r\n s> Transfer-Encoding: chunked\r\n s> \r\n - s> 25\r\n - s> \x1d\x00\x00\x01\x00\x02\x01Bcustomreadonly bytes response + s> 27\r\n + s> \x1f\x00\x00\x01\x00\x02\x01BX\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-0003\r\n - s> content-type: application/mercurial-exp-framing-0003\r\n + s> accept: application/mercurial-exp-framing-0004\r\n + s> content-type: application/mercurial-exp-framing-0004\r\n s> content-length: 29\r\n s> host: $LOCALIP:$HGPORT\r\n (glob) s> user-agent: Mercurial debugwireproto\r\n @@ -198,14 +198,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-0003\r\n + s> Content-Type: application/mercurial-exp-framing-0004\r\n s> Transfer-Encoding: chunked\r\n s> \r\n - s> 25\r\n - s> \x1d\x00\x00\x01\x00\x02\x01B - s> customreadonly bytes response + s> 27\r\n + s> \x1f\x00\x00\x01\x00\x02\x01B + s> X\x1dcustomreadonly bytes response s> \r\n - received frame(size=29; request=1; stream=2; streamflags=stream-begin; type=bytes-response; flags=eos) + received frame(size=31; request=1; stream=2; streamflags=stream-begin; type=bytes-response; flags=eos) s> 0\r\n s> \r\n response: [b'customreadonly bytes response'] @@ -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-0003\r\n - s> content-type: application/mercurial-exp-framing-0003\r\n + s> accept: application/mercurial-exp-framing-0004\r\n + s> content-type: application/mercurial-exp-framing-0004\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-0003\r\n + s> Content-Type: application/mercurial-exp-framing-0004\r\n s> Transfer-Encoding: chunked\r\n s> \r\n - s> 25\r\n - s> \x1d\x00\x00\x01\x00\x02\x01Bcustomreadonly bytes response + s> 27\r\n + s> \x1f\x00\x00\x01\x00\x02\x01BX\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-0003\r\n + s> accept: application/mercurial-exp-framing-0004\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-0003\r\n - s> content-type: application/mercurial-exp-framing-0003\r\n + s> accept: application/mercurial-exp-framing-0004\r\n + s> content-type: application/mercurial-exp-framing-0004\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-0003\r\n - s> content-type: application/mercurial-exp-framing-0003\r\n + s> accept: application/mercurial-exp-framing-0004\r\n + s> content-type: application/mercurial-exp-framing-0004\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-0003\r\n + s> Content-Type: application/mercurial-exp-framing-0004\r\n s> Transfer-Encoding: chunked\r\n s> \r\n - s> 25\r\n - s> \x1d\x00\x00\x01\x00\x02\x01Bcustomreadonly bytes response + s> 27\r\n + s> \x1f\x00\x00\x01\x00\x02\x01BX\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-0003\r\n + s> Content-Type: application/mercurial-exp-framing-0004\r\n s> Transfer-Encoding: chunked\r\n s> \r\n - s> 25\r\n - s> \x1d\x00\x00\x01\x00\x02\x01Bcustomreadonly bytes response + s> 27\r\n + s> \x1f\x00\x00\x01\x00\x02\x01BX\x1dcustomreadonly bytes response s> \r\n - s> 25\r\n - s> \x1d\x00\x00\x03\x00\x02\x00Bcustomreadonly bytes response + s> 27\r\n + s> \x1f\x00\x00\x03\x00\x02\x00BX\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-0003\r\n - s> content-type: application/mercurial-exp-framing-0003\r\n + s> accept: application/mercurial-exp-framing-0004\r\n + s> content-type: application/mercurial-exp-framing-0004\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-0003\r\n + s> Content-Type: application/mercurial-exp-framing-0004\r\n s> Transfer-Encoding: chunked\r\n s> \r\n s> 28\r\n - s> \x00\x00\x03\x00\x02\x01F\xa3Fphases@Ibookmarks@Jnamespaces@ + s> \x00\x00\x03\x00\x02\x01B\xa3Fphases@Ibookmarks@Jnamespaces@ s> \r\n s> 9\r\n - s> \x01\x00\x00\x01\x00\x02\x00F\xa0 + s> \x01\x00\x00\x01\x00\x02\x00B\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-0003\r\n - s> content-type: application/mercurial-exp-framing-0003\r\n + s> accept: application/mercurial-exp-framing-0004\r\n + s> content-type: application/mercurial-exp-framing-0004\r\n s> user-agent: test\r\n s> content-length: 22\r\n s> host: $LOCALIP:$HGPORT\r\n (glob)