Mercurial > hg
view tests/test-logexchange.t @ 37048:fc5e261915b9
wireproto: require POST for all HTTPv2 requests
Wire protocol version 1 transfers argument data via request
headers by default. This has historically caused problems because
servers institute limits on the length of individual HTTP headers
as well as the total size of all request headers. Mercurial servers
can advertise the maximum length of an individual header. But
there's no guarantee any intermediate HTTP agents will accept
headers up to that length.
In the existing wire protocol, server operators typically also
key off the HTTP request method to implement authentication.
For example, GET requests translate to read-only requests and
can be allowed. But read-write commands must use POST and require
authentication. This has typically worked because the only wire
protocol commands that use POST modify the repo (e.g. the
"unbundle" command).
There is an experimental feature to enable clients to transmit
argument data via POST request bodies. This is technically a
better and more robust solution. But we can't enable it by default
because of servers assuming POST means write access.
In version 2 of the wire protocol, the permissions of a request
are encoded in the URL. And with it being a new protocol in a new
URL space, we're not constrained by backwards compatibility
requirements.
This commit adopts the technically superior mechanism of using
HTTP request bodies to send argument data by requiring POST for
all commands. Strictly speaking, it may be possible to send
request bodies on GET requests. But my experience is that not all
HTTP stacks support this. POST pretty much always works. Using POST
for read-only operations does sacrifice some RESTful design
purity. But this API cares about practicality, not about being
in Roy T. Fielding's REST ivory tower.
There's a chance we may relax this restriction in the future. But
for now, I want to see how far we can get with a POST only API.
Differential Revision: https://phab.mercurial-scm.org/D2837
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 13 Mar 2018 11:57:43 -0700 |
parents | 18e29c65bc5c |
children | 9938992c5bae |
line wrap: on
line source
Testing the functionality to pull remotenames ============================================= $ cat >> $HGRCPATH << EOF > [alias] > glog = log -G -T '{rev}:{node|short} {desc}' > [experimental] > remotenames = True > [extensions] > remotenames = > show = > EOF Making a server repo -------------------- $ hg init server $ cd server $ for ch in a b c d e f g h; do > echo "foo" >> $ch > hg ci -Aqm "Added "$ch > done $ hg glog @ 7:ec2426147f0e Added h | o 6:87d6d6676308 Added g | o 5:825660c69f0c Added f | o 4:aa98ab95a928 Added e | o 3:62615734edd5 Added d | o 2:28ad74487de9 Added c | o 1:29becc82797a Added b | o 0:18d04c59bb5d Added a $ hg bookmark -r 3 foo $ hg bookmark -r 6 bar $ hg up 4 0 files updated, 0 files merged, 3 files removed, 0 files unresolved $ hg branch wat marked working directory as branch wat (branches are permanent and global, did you want a bookmark?) $ echo foo >> bar $ hg ci -Aqm "added bar" Making a client repo -------------------- $ cd .. $ hg clone server client updating to branch default 8 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd client $ cat .hg/logexchange/bookmarks 0 87d6d66763085b629e6d7ed56778c79827273022\x00default\x00bar (esc) 62615734edd52f06b6fb9c2beb429e4fe30d57b8\x00default\x00foo (esc) $ cat .hg/logexchange/branches 0 ec2426147f0e39dbc9cef599b066be6035ce691d\x00default\x00default (esc) 3e1487808078543b0af6d10dadf5d46943578db0\x00default\x00wat (esc) $ hg show work o 3e14 (wat) (default/wat) added bar | ~ @ ec24 (default/default) Added h | ~ $ hg update "default/wat" 1 files updated, 0 files merged, 3 files removed, 0 files unresolved $ hg identify 3e1487808078 (wat) tip Making a new server ------------------- $ cd .. $ hg init server2 $ cd server2 $ hg pull ../server/ pulling from ../server/ requesting all changes adding changesets adding manifests adding file changes added 9 changesets with 9 changes to 9 files (+1 heads) adding remote bookmark bar adding remote bookmark foo new changesets 18d04c59bb5d:3e1487808078 (run 'hg heads' to see heads) Pulling form the new server --------------------------- $ cd ../client/ $ hg pull ../server2/ pulling from ../server2/ searching for changes no changes found $ cat .hg/logexchange/bookmarks 0 62615734edd52f06b6fb9c2beb429e4fe30d57b8\x00default\x00foo (esc) 87d6d66763085b629e6d7ed56778c79827273022\x00default\x00bar (esc) 87d6d66763085b629e6d7ed56778c79827273022\x00$TESTTMP/server2\x00bar (esc) 62615734edd52f06b6fb9c2beb429e4fe30d57b8\x00$TESTTMP/server2\x00foo (esc) $ cat .hg/logexchange/branches 0 3e1487808078543b0af6d10dadf5d46943578db0\x00default\x00wat (esc) ec2426147f0e39dbc9cef599b066be6035ce691d\x00default\x00default (esc) ec2426147f0e39dbc9cef599b066be6035ce691d\x00$TESTTMP/server2\x00default (esc) 3e1487808078543b0af6d10dadf5d46943578db0\x00$TESTTMP/server2\x00wat (esc) $ hg log -G @ changeset: 8:3e1487808078 | branch: wat | tag: tip | remote branch: $TESTTMP/server2/wat | remote branch: default/wat | parent: 4:aa98ab95a928 | user: test | date: Thu Jan 01 00:00:00 1970 +0000 | summary: added bar | | o changeset: 7:ec2426147f0e | | remote branch: $TESTTMP/server2/default | | remote branch: default/default | | user: test | | date: Thu Jan 01 00:00:00 1970 +0000 | | summary: Added h | | | o changeset: 6:87d6d6676308 | | bookmark: bar | | remote bookmark: $TESTTMP/server2/bar | | remote bookmark: default/bar | | user: test | | date: Thu Jan 01 00:00:00 1970 +0000 | | summary: Added g | | | o changeset: 5:825660c69f0c |/ user: test | date: Thu Jan 01 00:00:00 1970 +0000 | summary: Added f | o changeset: 4:aa98ab95a928 | user: test | date: Thu Jan 01 00:00:00 1970 +0000 | summary: Added e | o changeset: 3:62615734edd5 | bookmark: foo | remote bookmark: $TESTTMP/server2/foo | remote bookmark: default/foo | user: test | date: Thu Jan 01 00:00:00 1970 +0000 | summary: Added d | o changeset: 2:28ad74487de9 | user: test | date: Thu Jan 01 00:00:00 1970 +0000 | summary: Added c | o changeset: 1:29becc82797a | user: test | date: Thu Jan 01 00:00:00 1970 +0000 | summary: Added b | o changeset: 0:18d04c59bb5d user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: Added a Testing the templates provided by remotenames extension `remotenames` keyword $ hg log -G -T "{rev}:{node|short} {remotenames}\n" @ 8:3e1487808078 $TESTTMP/server2/wat default/wat | | o 7:ec2426147f0e $TESTTMP/server2/default default/default | | | o 6:87d6d6676308 $TESTTMP/server2/bar default/bar | | | o 5:825660c69f0c |/ o 4:aa98ab95a928 | o 3:62615734edd5 $TESTTMP/server2/foo default/foo | o 2:28ad74487de9 | o 1:29becc82797a | o 0:18d04c59bb5d `remotebookmarks` and `remotebranches` keywords $ hg log -G -T "{rev}:{node|short} [{remotebookmarks}] ({remotebranches})" @ 8:3e1487808078 [] ($TESTTMP/server2/wat default/wat) | | o 7:ec2426147f0e [] ($TESTTMP/server2/default default/default) | | | o 6:87d6d6676308 [$TESTTMP/server2/bar default/bar] () | | | o 5:825660c69f0c [] () |/ o 4:aa98ab95a928 [] () | o 3:62615734edd5 [$TESTTMP/server2/foo default/foo] () | o 2:28ad74487de9 [] () | o 1:29becc82797a [] () | o 0:18d04c59bb5d [] () Testing the revsets provided by remotenames extension `remotenames` revset $ hg log -r "remotenames()" -GT "{rev}:{node|short} {remotenames}\n" @ 8:3e1487808078 $TESTTMP/server2/wat default/wat : : o 7:ec2426147f0e $TESTTMP/server2/default default/default : | : o 6:87d6d6676308 $TESTTMP/server2/bar default/bar :/ o 3:62615734edd5 $TESTTMP/server2/foo default/foo | ~ `remotebranches` revset $ hg log -r "remotebranches()" -GT "{rev}:{node|short} {remotenames}\n" @ 8:3e1487808078 $TESTTMP/server2/wat default/wat | ~ o 7:ec2426147f0e $TESTTMP/server2/default default/default | ~ `remotebookmarks` revset $ hg log -r "remotebookmarks()" -GT "{rev}:{node|short} {remotenames}\n" o 6:87d6d6676308 $TESTTMP/server2/bar default/bar : o 3:62615734edd5 $TESTTMP/server2/foo default/foo | ~