annotate contrib/chg/procutil.h @ 37557:734515aca84d

wireproto: define and implement HTTP handshake to upgrade protocol When clients connect to repositories over HTTP, they issue a request to the well-known URL "?cmd=capabilities" to fetch the repository capabilities. This is the handshake portion of the HTTP protocol. This commit defines a mechanism to use that HTTP request to return information about modern server features. If a client sends an X-HgUpgrade-* header containing a list of client-supported API names, the server responds with a response containing information about available services. This includes the normal capabilities string. So if the server doesn't support any newer services, the client can easily fall back. By advertising supported services from clients, server operators can see and log what client support exists in the wild. This will also help with debugging. The response contains the base path to API services. We know there are potential issues with the <repo>/api/ URL space conflicting with hgwebdir and subrepos. By making the API URL dynamic from the perspective of the client, the URL for APIs is not subject to backwards compatibility concerns - at least as long as a ?cmd=capabilities request is made. We've also defined the ``cbor`` client capability for the X-HgProto-* header. This MUST be sent in order to get the modern response from "?cmd=capabilities". During implementation, I initially always sent an application/mercurial-cbor response. However, the handshake mechanism will be more future compatible if the client is in charge of which formats to request. We already perform content negotiation from X-HgProto-*, so keying off this for the capabilities response feels appropriate. In addition, I initially used application/cbor. However, it is conceivable that a non-Mercurial server could serve application/cbor. To rule out this possibility, I've invented a new media type that is Mercurial specific and can't be confused for generic CBOR. Differential Revision: https://phab.mercurial-scm.org/D3242
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 10 Apr 2018 14:29:15 -0700
parents ac5527021097
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30693
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
1 /*
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
2 * Utilities about process handling - signal and subprocess (ex. pager)
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
3 *
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
4 * Copyright (c) 2011 Yuya Nishihara <yuya@tcha.org>
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
5 *
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
6 * This software may be used and distributed according to the terms of the
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
7 * GNU General Public License version 2 or any later version.
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
8 */
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
9
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
10 #ifndef PROCUTIL_H_
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
11 #define PROCUTIL_H_
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
12
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
13 #include <unistd.h>
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
14
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
15 void restoresignalhandler(void);
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
16 void setupsignalhandler(pid_t pid, pid_t pgid);
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
17
31941
ac5527021097 chg: respect environment variables for pager
Jun Wu <quark@fb.com>
parents: 30693
diff changeset
18 pid_t setuppager(const char *pagercmd, const char *envp[]);
30693
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
19 void waitpager(void);
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
20
baee0f47b533 chg: add procutil.h
Jun Wu <quark@fb.com>
parents:
diff changeset
21 #endif /* PROCUTIL_H_ */