tests/test-http-protocol.t
changeset 37558 8a73132214a3
parent 37556 b77aa48ba690
child 37645 72b0982cd509
equal deleted inserted replaced
37557:734515aca84d 37558:8a73132214a3
       
     1   $ . $TESTDIR/wireprotohelpers.sh
       
     2 
     1   $ cat >> $HGRCPATH << EOF
     3   $ cat >> $HGRCPATH << EOF
     2   > [web]
     4   > [web]
     3   > push_ssl = false
     5   > push_ssl = false
     4   > allow_push = *
     6   > allow_push = *
     5   > EOF
     7   > EOF
   234   s>     \r\n
   236   s>     \r\n
   235   s>     bookmarks\t\n
   237   s>     bookmarks\t\n
   236   s>     namespaces\t\n
   238   s>     namespaces\t\n
   237   s>     phases\t
   239   s>     phases\t
   238 
   240 
   239   $ killdaemons.py
   241 Client with HTTPv2 enabled advertises that and gets old capabilities response from old server
       
   242 
       
   243   $ hg --config experimental.httppeer.advertise-v2=true --verbose debugwireproto http://$LOCALIP:$HGPORT << EOF
       
   244   > command heads
       
   245   > EOF
       
   246   s>     GET /?cmd=capabilities HTTP/1.1\r\n
       
   247   s>     Accept-Encoding: identity\r\n
       
   248   s>     vary: X-HgProto-1,X-HgUpgrade-1\r\n
       
   249   s>     x-hgproto-1: cbor\r\n
       
   250   s>     x-hgupgrade-1: exp-http-v2-0001\r\n
       
   251   s>     accept: application/mercurial-0.1\r\n
       
   252   s>     host: $LOCALIP:$HGPORT\r\n (glob)
       
   253   s>     user-agent: Mercurial debugwireproto\r\n
       
   254   s>     \r\n
       
   255   s> makefile('rb', None)
       
   256   s>     HTTP/1.1 200 Script output follows\r\n
       
   257   s>     Server: testing stub value\r\n
       
   258   s>     Date: $HTTP_DATE$\r\n
       
   259   s>     Content-Type: application/mercurial-0.1\r\n
       
   260   s>     Content-Length: 458\r\n
       
   261   s>     \r\n
       
   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
       
   263   sending heads command
       
   264   s>     GET /?cmd=heads HTTP/1.1\r\n
       
   265   s>     Accept-Encoding: identity\r\n
       
   266   s>     vary: X-HgProto-1\r\n
       
   267   s>     x-hgproto-1: 0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull\r\n
       
   268   s>     accept: application/mercurial-0.1\r\n
       
   269   s>     host: $LOCALIP:$HGPORT\r\n (glob)
       
   270   s>     user-agent: Mercurial debugwireproto\r\n
       
   271   s>     \r\n
       
   272   s> makefile('rb', None)
       
   273   s>     HTTP/1.1 200 Script output follows\r\n
       
   274   s>     Server: testing stub value\r\n
       
   275   s>     Date: $HTTP_DATE$\r\n
       
   276   s>     Content-Type: application/mercurial-0.1\r\n
       
   277   s>     Content-Length: 41\r\n
       
   278   s>     \r\n
       
   279   s>     0000000000000000000000000000000000000000\n
       
   280   response: b'0000000000000000000000000000000000000000\n'
       
   281 
       
   282   $ killdaemons.py
       
   283   $ enablehttpv2 empty
       
   284   $ hg -R empty serve -p $HGPORT -d --pid-file hg.pid
       
   285   $ cat hg.pid > $DAEMON_PIDS
       
   286 
       
   287 Client with HTTPv2 enabled automatically upgrades if the server supports it
       
   288 
       
   289   $ hg --config experimental.httppeer.advertise-v2=true --verbose debugwireproto http://$LOCALIP:$HGPORT << EOF
       
   290   > command heads
       
   291   > EOF
       
   292   s>     GET /?cmd=capabilities HTTP/1.1\r\n
       
   293   s>     Accept-Encoding: identity\r\n
       
   294   s>     vary: X-HgProto-1,X-HgUpgrade-1\r\n
       
   295   s>     x-hgproto-1: cbor\r\n
       
   296   s>     x-hgupgrade-1: exp-http-v2-0001\r\n
       
   297   s>     accept: application/mercurial-0.1\r\n
       
   298   s>     host: $LOCALIP:$HGPORT\r\n (glob)
       
   299   s>     user-agent: Mercurial debugwireproto\r\n
       
   300   s>     \r\n
       
   301   s> makefile('rb', None)
       
   302   s>     HTTP/1.1 200 OK\r\n
       
   303   s>     Server: testing stub value\r\n
       
   304   s>     Date: $HTTP_DATE$\r\n
       
   305   s>     Content-Type: application/mercurial-cbor\r\n
       
   306   s>     Content-Length: 879\r\n
       
   307   s>     \r\n
       
   308   s>     \xa3Dapis\xa1Pexp-http-v2-0001\xa2Hcommands\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\xa1DnameDzlibGapibaseDapi/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
       
   309   sending heads command
       
   310   s>     POST /api/exp-http-v2-0001/ro/heads HTTP/1.1\r\n
       
   311   s>     Accept-Encoding: identity\r\n
       
   312   s>     accept: application/mercurial-exp-framing-0003\r\n
       
   313   s>     content-type: application/mercurial-exp-framing-0003\r\n
       
   314   s>     content-length: 20\r\n
       
   315   s>     host: $LOCALIP:$HGPORT\r\n (glob)
       
   316   s>     user-agent: Mercurial debugwireproto\r\n
       
   317   s>     \r\n
       
   318   s>     \x0c\x00\x00\x01\x00\x01\x01\x11\xa1DnameEheads
       
   319   s> makefile('rb', None)
       
   320   s>     HTTP/1.1 200 OK\r\n
       
   321   s>     Server: testing stub value\r\n
       
   322   s>     Date: $HTTP_DATE$\r\n
       
   323   s>     Content-Type: application/mercurial-exp-framing-0003\r\n
       
   324   s>     Transfer-Encoding: chunked\r\n
       
   325   s>     \r\n
       
   326   s>     1e\r\n
       
   327   s>     \x16\x00\x00\x01\x00\x02\x01F
       
   328   s>     \x81T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
       
   329   s>     \r\n
       
   330   received frame(size=22; request=1; stream=2; streamflags=stream-begin; type=bytes-response; flags=eos|cbor)
       
   331   s>     0\r\n
       
   332   s>     \r\n
       
   333   response: [[b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00']]
       
   334 
       
   335   $ killdaemons.py