tests/test-http-protocol.t
changeset 30764 e75463e3179f
parent 30762 35b516f800e0
child 30840 a1dd2c0c479e
equal deleted inserted replaced
30763:a520aefb96f1 30764:e75463e3179f
    40   $ cat hg.pid > $DAEMON_PIDS
    40   $ cat hg.pid > $DAEMON_PIDS
    41   $ get-with-headers.py 127.0.0.1:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep compression
    41   $ get-with-headers.py 127.0.0.1:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep compression
    42   compression=none,zlib
    42   compression=none,zlib
    43 
    43 
    44   $ killdaemons.py
    44   $ killdaemons.py
       
    45 
       
    46 Start a default server again
       
    47 
       
    48   $ hg -R server serve -p $HGPORT -d --pid-file hg.pid
       
    49   $ cat hg.pid > $DAEMON_PIDS
       
    50 
       
    51 Server should send application/mercurial-0.1 to clients if no Accept is used
       
    52 
       
    53   $ get-with-headers.py --headeronly 127.0.0.1:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' -
       
    54   200 Script output follows
       
    55   content-type: application/mercurial-0.1
       
    56   date: * (glob)
       
    57   server: * (glob)
       
    58   transfer-encoding: chunked
       
    59 
       
    60 Server should send application/mercurial-0.1 when client says it wants it
       
    61 
       
    62   $ get-with-headers.py --hgproto '0.1' --headeronly 127.0.0.1:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' -
       
    63   200 Script output follows
       
    64   content-type: application/mercurial-0.1
       
    65   date: * (glob)
       
    66   server: * (glob)
       
    67   transfer-encoding: chunked
       
    68 
       
    69 Server should send application/mercurial-0.2 when client says it wants it
       
    70 
       
    71   $ get-with-headers.py --hgproto '0.2' --headeronly 127.0.0.1:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' -
       
    72   200 Script output follows
       
    73   content-type: application/mercurial-0.2
       
    74   date: * (glob)
       
    75   server: * (glob)
       
    76   transfer-encoding: chunked
       
    77 
       
    78   $ get-with-headers.py --hgproto '0.1 0.2' --headeronly 127.0.0.1:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' -
       
    79   200 Script output follows
       
    80   content-type: application/mercurial-0.2
       
    81   date: * (glob)
       
    82   server: * (glob)
       
    83   transfer-encoding: chunked
       
    84 
       
    85 Requesting a compression format that server doesn't support results will fall back to 0.1
       
    86 
       
    87   $ get-with-headers.py --hgproto '0.2 comp=aa' --headeronly 127.0.0.1:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' -
       
    88   200 Script output follows
       
    89   content-type: application/mercurial-0.1
       
    90   date: * (glob)
       
    91   server: * (glob)
       
    92   transfer-encoding: chunked
       
    93 
       
    94 #if zstd
       
    95 zstd is used if available
       
    96 
       
    97   $ get-with-headers.py --hgproto '0.2 comp=zstd' 127.0.0.1:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' > resp
       
    98   $ f --size --hexdump --bytes 36 --sha1 resp
       
    99   resp: size=248, sha1=4d8d8f87fb82bd542ce52881fdc94f850748
       
   100   0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
       
   101   0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 04 7a 73 74 64 |t follows...zstd|
       
   102   0020: 28 b5 2f fd                                     |(./.|
       
   103 
       
   104 #endif
       
   105 
       
   106 application/mercurial-0.2 is not yet used on non-streaming responses
       
   107 
       
   108   $ get-with-headers.py --hgproto '0.2' 127.0.0.1:$HGPORT '?cmd=heads' -
       
   109   200 Script output follows
       
   110   content-length: 41
       
   111   content-type: application/mercurial-0.1
       
   112   date: * (glob)
       
   113   server: * (glob)
       
   114   
       
   115   e93700bd72895c5addab234c56d4024b487a362f
       
   116 
       
   117 Now test protocol preference usage
       
   118 
       
   119   $ killdaemons.py
       
   120   $ hg --config server.compressionengines=none,zlib -R server serve -p $HGPORT -d --pid-file hg.pid
       
   121   $ cat hg.pid > $DAEMON_PIDS
       
   122 
       
   123 No Accept will send 0.1+zlib, even though "none" is preferred b/c "none" isn't supported on 0.1
       
   124 
       
   125   $ get-with-headers.py --headeronly 127.0.0.1:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000' Content-Type
       
   126   200 Script output follows
       
   127   content-type: application/mercurial-0.1
       
   128 
       
   129   $ get-with-headers.py 127.0.0.1:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000'  > resp
       
   130   $ f --size --hexdump --bytes 28 --sha1 resp
       
   131   resp: size=227, sha1=35a4c074da74f32f5440da3cbf04
       
   132   0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
       
   133   0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 78             |t follows..x|
       
   134 
       
   135 Explicit 0.1 will send zlib because "none" isn't supported on 0.1
       
   136 
       
   137   $ get-with-headers.py --hgproto '0.1' 127.0.0.1:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000'  > resp
       
   138   $ f --size --hexdump --bytes 28 --sha1 resp
       
   139   resp: size=227, sha1=35a4c074da74f32f5440da3cbf04
       
   140   0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
       
   141   0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 78             |t follows..x|
       
   142 
       
   143 0.2 with no compression will get "none" because that is server's preference
       
   144 (spec says ZL and UN are implicitly supported)
       
   145 
       
   146   $ get-with-headers.py --hgproto '0.2' 127.0.0.1:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000'  > resp
       
   147   $ f --size --hexdump --bytes 32 --sha1 resp
       
   148   resp: size=432, sha1=ac931b412ec185a02e0e5bcff98dac83
       
   149   0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
       
   150   0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 04 6e 6f 6e 65 |t follows...none|
       
   151 
       
   152 Client receives server preference even if local order doesn't match
       
   153 
       
   154   $ get-with-headers.py --hgproto '0.2 comp=zlib,none' 127.0.0.1:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000'  > resp
       
   155   $ f --size --hexdump --bytes 32 --sha1 resp
       
   156   resp: size=432, sha1=ac931b412ec185a02e0e5bcff98dac83
       
   157   0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
       
   158   0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 04 6e 6f 6e 65 |t follows...none|
       
   159 
       
   160 Client receives only supported format even if not server preferred format
       
   161 
       
   162   $ get-with-headers.py --hgproto '0.2 comp=zlib' 127.0.0.1:$HGPORT '?cmd=getbundle&heads=e93700bd72895c5addab234c56d4024b487a362f&common=0000000000000000000000000000000000000000'  > resp
       
   163   $ f --size --hexdump --bytes 33 --sha1 resp
       
   164   resp: size=232, sha1=a1c727f0c9693ca15742a75c30419bc36
       
   165   0000: 32 30 30 20 53 63 72 69 70 74 20 6f 75 74 70 75 |200 Script outpu|
       
   166   0010: 74 20 66 6f 6c 6c 6f 77 73 0a 0a 04 7a 6c 69 62 |t follows...zlib|
       
   167   0020: 78                                              |x|