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