mercurial/helptext/internals/wireprotocolrpc.txt
author Matt Harbison <matt_harbison@yahoo.com>
Thu, 05 Jan 2023 17:38:14 -0500
branchstable
changeset 49883 e90767a71dc0
parent 43632 2e017696181f
permissions -rw-r--r--
histedit: byteify the help for the multifold action While there's some allowance for str in `_()`, it's commented to be for "goofy unicode docstrings in test", so no idea how well that works, but it should at least come back as bytes. With HGPLAIN, however, the str isn't touched and is returned as-is, so this seems like a real bug.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
     1
**Experimental and under development**
35976
48a3a9283f09 sshpeer: initial definition and implementation of new SSH protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35975
diff changeset
     2
39558
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
     3
This document describe's Mercurial's transport-agnostic remote procedure
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
     4
call (RPC) protocol which is used to perform interactions with remote
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
     5
servers. This protocol is also referred to as ``hgrpc``.
35976
48a3a9283f09 sshpeer: initial definition and implementation of new SSH protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35975
diff changeset
     6
39558
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
     7
The protocol has the following high-level features:
35976
48a3a9283f09 sshpeer: initial definition and implementation of new SSH protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35975
diff changeset
     8
39558
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
     9
* Concurrent request and response support (multiple commands can be issued
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    10
  simultaneously and responses can be streamed simultaneously).
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    11
* Supports half-duplex and full-duplex connections.
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    12
* All data is transmitted within *frames*, which have a well-defined
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    13
  header and encode their length.
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    14
* Side-channels for sending progress updates and printing output. Text
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    15
  output from the remote can be localized locally.
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    16
* Support for simultaneous and long-lived compression streams, even across
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    17
  requests.
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    18
* Uses CBOR for data exchange.
35976
48a3a9283f09 sshpeer: initial definition and implementation of new SSH protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35975
diff changeset
    19
39558
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    20
The protocol is not specific to Mercurial and could be used by other
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    21
applications.
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    22
39558
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    23
High-level Overview
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    24
===================
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    25
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    26
To operate the protocol, a bi-directional, half-duplex pipe supporting
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    27
ordered sends and receives is required. That is, each peer has one pipe
39558
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    28
for sending data and another for receiving. Full-duplex pipes are also
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    29
supported.
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    30
37288
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    31
All data is read and written in atomic units called *frames*. These
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    32
are conceptually similar to TCP packets. Higher-level functionality
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    33
is built on the exchange and processing of frames.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    34
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    35
All frames are associated with a *stream*. A *stream* provides a
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    36
unidirectional grouping of frames. Streams facilitate two goals:
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    37
content encoding and parallelism. There is a dedicated section on
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    38
streams below.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    39
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    40
The protocol is request-response based: the client issues requests to
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    41
the server, which issues replies to those requests. Server-initiated
37057
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
    42
messaging is not currently supported, but this specification carves
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
    43
out room to implement it.
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    44
37057
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
    45
All frames are associated with a numbered request. Frames can thus
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
    46
be logically grouped by their request ID.
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
    47
39558
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    48
Frames
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    49
======
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
    50
37288
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    51
Frames begin with an 8 octet header followed by a variable length
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    52
payload::
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    53
37288
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    54
    +------------------------------------------------+
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    55
    |                 Length (24)                    |
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    56
    +--------------------------------+---------------+
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    57
    |         Request ID (16)        | Stream ID (8) |
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    58
    +------------------+-------------+---------------+
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    59
    | Stream Flags (8) |
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    60
    +-----------+------+
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    61
    | Type (4)  |
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    62
    +-----------+
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    63
    | Flags (4) |
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    64
    +===========+===================================================|
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    65
    |                     Frame Payload (0...)                    ...
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    66
    +---------------------------------------------------------------+
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    67
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    68
The length of the frame payload is expressed as an unsigned 24 bit
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    69
little endian integer. Values larger than 65535 MUST NOT be used unless
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    70
given permission by the server as part of the negotiated capabilities
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    71
during the handshake. The frame header is not part of the advertised
37288
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    72
frame length. The payload length is the over-the-wire length. If there
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    73
is content encoding applied to the payload as part of the frame's stream,
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    74
the length is the output of that content encoding, not the input.
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    75
37057
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
    76
The 16-bit ``Request ID`` field denotes the integer request identifier,
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
    77
stored as an unsigned little endian integer. Odd numbered requests are
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
    78
client-initiated. Even numbered requests are server-initiated. This
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
    79
refers to where the *request* was initiated - not where the *frame* was
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
    80
initiated, so servers will send frames with odd ``Request ID`` in
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
    81
response to client-initiated requests. Implementations are advised to
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
    82
start ordering request identifiers at ``1`` and ``0``, increment by
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
    83
``2``, and wrap around if all available numbers have been exhausted.
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
    84
37288
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    85
The 8-bit ``Stream ID`` field denotes the stream that the frame is
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    86
associated with. Frames belonging to a stream may have content
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    87
encoding applied and the receiver may need to decode the raw frame
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    88
payload to obtain the original data. Odd numbered IDs are
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    89
client-initiated. Even numbered IDs are server-initiated.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    90
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    91
The 8-bit ``Stream Flags`` field defines stream processing semantics.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    92
See the section on streams below.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    93
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
    94
The 4-bit ``Type`` field denotes the type of frame being sent.
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    95
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    96
The 4-bit ``Flags`` field defines special, per-type attributes for
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    97
the frame.
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    98
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
    99
The sections below define the frame types and their behavior.
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   100
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   101
Command Request (``0x01``)
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   102
--------------------------
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   103
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   104
This frame contains a request to run a command.
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   105
37292
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   106
The payload consists of a CBOR map defining the command request. The
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   107
bytestring keys of that map are:
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   108
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   109
name
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   110
   Name of the command that should be executed (bytestring).
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   111
args
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   112
   Map of bytestring keys to various value types containing the named
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   113
   arguments to this command.
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   114
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   115
   Each command defines its own set of argument names and their expected
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   116
   types.
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   117
40022
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   118
redirect (optional)
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   119
   (map) Advertises client support for following response *redirects*.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   120
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   121
   This map has the following bytestring keys:
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   122
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   123
   targets
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   124
      (array of bytestring) List of named redirect targets supported by
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   125
      this client. The names come from the targets advertised by the
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   126
      server's *capabilities* message.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   127
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   128
   hashes
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   129
      (array of bytestring) List of preferred hashing algorithms that can
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   130
      be used for content integrity verification.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   131
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   132
   See the *Content Redirects* section below for more on content redirects.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   133
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   134
This frame type MUST ONLY be sent from clients to servers: it is illegal
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   135
for a server to send this frame to a client.
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   136
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   137
The following flag values are defined for this type:
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   138
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   139
0x01
37292
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   140
   New command request. When set, this frame represents the beginning
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   141
   of a new request to run a command. The ``Request ID`` attached to this
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   142
   frame MUST NOT be active.
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   143
0x02
37292
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   144
   Command request continuation. When set, this frame is a continuation
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   145
   from a previous command request frame for its ``Request ID``. This
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   146
   flag is set when the CBOR data for a command request does not fit
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   147
   in a single frame.
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   148
0x04
37292
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   149
   Additional frames expected. When set, the command request didn't fit
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   150
   into a single frame and additional CBOR data follows in a subsequent
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   151
   frame.
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   152
0x08
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   153
   Command data frames expected. When set, command data frames are
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   154
   expected to follow the final command request frame for this request.
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   155
37292
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   156
``0x01`` MUST be set on the initial command request frame for a
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   157
``Request ID``.
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   158
37292
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   159
``0x01`` or ``0x02`` MUST be set to indicate this frame's role in
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   160
a series of command request frames.
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   161
37723
e8fba6d578f0 wireprotov2: change frame type value for command data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37722
diff changeset
   162
If command data frames are to be sent, ``0x08`` MUST be set on ALL
37292
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   163
command request frames.
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   164
37723
e8fba6d578f0 wireprotov2: change frame type value for command data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37722
diff changeset
   165
Command Data (``0x02``)
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   166
-----------------------
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   167
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   168
This frame contains raw data for a command.
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   169
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   170
Most commands can be executed by specifying arguments. However,
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   171
arguments have an upper bound to their length. For commands that
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   172
accept data that is beyond this length or whose length isn't known
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   173
when the command is initially sent, they will need to stream
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   174
arbitrary data to the server. This frame type facilitates the sending
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   175
of this data.
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   176
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   177
The payload of this frame type consists of a stream of raw data to be
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   178
consumed by the command handler on the server. The format of the data
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   179
is command specific.
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   180
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   181
The following flag values are defined for this type:
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   182
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   183
0x01
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   184
   Command data continuation. When set, the data for this command
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   185
   continues into a subsequent frame.
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   186
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   187
0x02
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   188
   End of data. When set, command data has been fully sent to the
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   189
   server. The command has been fully issued and no new data for this
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   190
   command will be sent. The next frame will belong to a new command.
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   191
37724
deff7cf7eefd wireprotov2: change frame type and name for command response
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37723
diff changeset
   192
Command Response Data (``0x03``)
deff7cf7eefd wireprotov2: change frame type and name for command response
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37723
diff changeset
   193
--------------------------------
37055
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   194
37722
89a16704114c wireprotov2: define response data as CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37657
diff changeset
   195
This frame contains response data to an issued command.
89a16704114c wireprotov2: define response data as CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37657
diff changeset
   196
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   197
Response data ALWAYS consists of a series of 1 or more CBOR encoded
37722
89a16704114c wireprotov2: define response data as CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37657
diff changeset
   198
values. A CBOR value may be using indefinite length encoding. And the
89a16704114c wireprotov2: define response data as CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37657
diff changeset
   199
bytes constituting the value may span several frames.
37055
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   200
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   201
The following flag values are defined for this type:
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   202
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   203
0x01
37299
e9aadee698cf wireproto: add frame flag to denote payloads as CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37292
diff changeset
   204
   Data continuation. When set, an additional frame containing response data
e9aadee698cf wireproto: add frame flag to denote payloads as CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37292
diff changeset
   205
   will follow.
37055
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   206
0x02
37299
e9aadee698cf wireproto: add frame flag to denote payloads as CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37292
diff changeset
   207
   End of data. When set, the response data has been fully sent and
37055
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   208
   no additional frames for this response will be sent.
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   209
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   210
The ``0x01`` flag is mutually exclusive with the ``0x02`` flag.
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   211
37726
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   212
Error Occurred (``0x05``)
37055
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   213
-------------------------
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   214
37726
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   215
Some kind of error occurred.
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   216
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   217
There are 3 general kinds of failures that can occur:
37055
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   218
37726
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   219
* Command error encountered before any response issued
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   220
* Command error encountered after a response was issued
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   221
* Protocol or stream level error
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   222
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   223
This frame type is used to capture the latter cases. (The general
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   224
command error case is handled by the leading CBOR map in
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   225
``Command Response`` frames.)
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   226
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   227
The payload of this frame contains a CBOR map detailing the error. That
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   228
map has the following bytestring keys:
37055
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   229
37726
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   230
type
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   231
   (bytestring) The overall type of error encountered. Can be one of the
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   232
   following values:
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   233
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   234
   protocol
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   235
      A protocol-level error occurred. This typically means someone
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   236
      is violating the framing protocol semantics and the server is
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   237
      refusing to proceed.
37055
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   238
37726
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   239
   server
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   240
      A server-level error occurred. This typically indicates some kind of
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   241
      logic error on the server, likely the fault of the server.
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   242
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   243
   command
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   244
      A command-level error, likely the fault of the client.
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   245
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   246
message
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   247
   (array of maps) A richly formatted message that is intended for
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   248
   human consumption. See the ``Human Output Side-Channel`` frame
0c184ca594bb wireprotov2: change behavior of error frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
   249
   section for a description of the format of this data structure.
37055
61393f888dfe wireproto: define and implement responses in framing protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37051
diff changeset
   250
37060
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   251
Human Output Side-Channel (``0x06``)
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   252
------------------------------------
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   253
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   254
This frame contains a message that is intended to be displayed to
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   255
people. Whereas most frames communicate machine readable data, this
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   256
frame communicates textual data that is intended to be shown to
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   257
humans.
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   258
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   259
The frame consists of a series of *formatting requests*. Each formatting
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   260
request consists of a formatting string, arguments for that formatting
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   261
string, and labels to apply to that formatting string.
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   262
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   263
A formatting string is a printf()-like string that allows variable
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   264
substitution within the string. Labels allow the rendered text to be
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   265
*decorated*. Assuming use of the canonical Mercurial code base, a
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   266
formatting string can be the input to the ``i18n._`` function. This
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   267
allows messages emitted from the server to be localized. So even if
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   268
the server has different i18n settings, people could see messages in
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   269
their *native* settings. Similarly, the use of labels allows
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   270
decorations like coloring and underlining to be applied using the
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   271
client's configured rendering settings.
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   272
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   273
Formatting strings are similar to ``printf()`` strings or how
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   274
Python's ``%`` operator works. The only supported formatting sequences
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   275
are ``%s`` and ``%%``. ``%s`` will be replaced by whatever the string
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   276
at that position resolves to. ``%%`` will be replaced by ``%``. All
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   277
other 2-byte sequences beginning with ``%`` represent a literal
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   278
``%`` followed by that character. However, future versions of the
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   279
wire protocol reserve the right to allow clients to opt in to receiving
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   280
formatting strings with additional formatters, hence why ``%%`` is
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   281
required to represent the literal ``%``.
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   282
37319
36d17f37db91 wireproto: convert human output frames to CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37299
diff changeset
   283
The frame payload consists of a CBOR array of CBOR maps. Each map
36d17f37db91 wireproto: convert human output frames to CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37299
diff changeset
   284
defines an *atom* of text data to print. Each *atom* has the following
36d17f37db91 wireproto: convert human output frames to CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37299
diff changeset
   285
bytestring keys:
37060
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   286
37319
36d17f37db91 wireproto: convert human output frames to CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37299
diff changeset
   287
msg
36d17f37db91 wireproto: convert human output frames to CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37299
diff changeset
   288
   (bytestring) The formatting string. Content MUST be ASCII.
36d17f37db91 wireproto: convert human output frames to CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37299
diff changeset
   289
args (optional)
36d17f37db91 wireproto: convert human output frames to CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37299
diff changeset
   290
   Array of bytestrings defining arguments to the formatting string.
36d17f37db91 wireproto: convert human output frames to CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37299
diff changeset
   291
labels (optional)
36d17f37db91 wireproto: convert human output frames to CBOR
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37299
diff changeset
   292
   Array of bytestrings defining labels to apply to this atom.
37129
aaabd709df72 wireproto: review fixups
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37060
diff changeset
   293
37060
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   294
All data to be printed MUST be encoded into a single frame: this frame
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   295
does not support spanning data across multiple frames.
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   296
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   297
All textual data encoded in these frames is assumed to be line delimited.
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   298
The last atom in the frame SHOULD end with a newline (``\n``). If it
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   299
doesn't, clients MAY add a newline to facilitate immediate printing.
0a6c5cc09a88 wireproto: define human output side channel frame
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37059
diff changeset
   300
37291
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   301
Progress Update (``0x07``)
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   302
--------------------------
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   303
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   304
This frame holds the progress of an operation on the peer. Consumption
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   305
of these frames allows clients to display progress bars, estimated
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   306
completion times, etc.
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   307
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   308
Each frame defines the progress of a single operation on the peer. The
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   309
payload consists of a CBOR map with the following bytestring keys:
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   310
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   311
topic
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   312
   Topic name (string)
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   313
pos
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   314
   Current numeric position within the topic (integer)
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   315
total
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   316
   Total/end numeric position of this topic (unsigned integer)
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   317
label (optional)
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   318
   Unit label (string)
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   319
item (optional)
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   320
   Item name (string)
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   321
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   322
Progress state is created when a frame is received referencing a
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   323
*topic* that isn't currently tracked. Progress tracking for that
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   324
*topic* is finished when a frame is received reporting the current
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   325
position of that topic as ``-1``.
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   326
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   327
Multiple *topics* may be active at any given time.
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   328
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   329
Rendering of progress information is not mandated or governed by this
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   330
specification: implementations MAY render progress information however
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   331
they see fit, including not at all.
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   332
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   333
The string data describing the topic SHOULD be static strings to
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   334
facilitate receivers localizing that string data. The emitter
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   335
MUST normalize all string data to valid UTF-8 and receivers SHOULD
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   336
validate that received data conforms to UTF-8. The topic name
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   337
SHOULD be ASCII.
b0041036214e wireproto: define frame to represent progress updates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37288
diff changeset
   338
40125
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   339
Sender Protocol Settings (``0x08``)
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   340
-----------------------------------
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   341
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   342
This frame type advertises the sender's support for various protocol and
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   343
stream level features. The data advertised in this frame is used to influence
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   344
subsequent behavior of the current frame exchange channel.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   345
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   346
The frame payload consists of a CBOR map. It may contain the following
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   347
bytestring keys:
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   348
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   349
contentencodings
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   350
   (array of bytestring) A list of content encodings supported by the
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   351
   sender, in order of most to least preferred.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   352
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   353
   Peers are allowed to encode stream data using any of the listed
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   354
   encodings.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   355
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   356
   See the ``Content Encoding Profiles`` section for an enumeration
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   357
   of supported content encodings.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   358
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   359
   If not defined, the value is assumed to be a list with the single value
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   360
   ``identity``, meaning only the no-op encoding is supported.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   361
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   362
   Senders MAY filter the set of advertised encodings against what it
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   363
   knows the receiver supports (e.g. if the receiver advertised encodings
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   364
   via the capabilities descriptor). However, doing so will prevent
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   365
   servers from gaining an understanding of the aggregate capabilities
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   366
   of clients. So clients are discouraged from doing so.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   367
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   368
When this frame is not sent/received, the receiver assumes default values
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   369
for all keys.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   370
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   371
If encountered, this frame type MUST be sent before any other frame type
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   372
in a channel.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   373
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   374
The following flag values are defined for this frame type:
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   375
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   376
0x01
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   377
   Data continuation. When set, an additional frame containing more protocol
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   378
   settings immediately follows.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   379
0x02
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   380
   End of data. When set, the protocol settings data has been completely
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   381
   sent.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   382
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   383
The ``0x01`` flag is mutually exclusive with the ``0x02`` flag.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   384
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   385
Stream Encoding Settings (``0x09``)
37288
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   386
-----------------------------------
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   387
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   388
This frame type holds information defining the content encoding
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   389
settings for a *stream*.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   390
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   391
This frame type is likely consumed by the protocol layer and is not
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   392
passed on to applications.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   393
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   394
This frame type MUST ONLY occur on frames having the *Beginning of Stream*
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   395
``Stream Flag`` set.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   396
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   397
The payload of this frame defines what content encoding has (possibly)
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   398
been applied to the payloads of subsequent frames in this stream.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   399
40125
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   400
The payload consists of a series of CBOR values. The first value is a
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   401
bytestring denoting the content encoding profile of the data in this
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   402
stream. Subsequent CBOR values supplement this simple value in a
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   403
profile-specific manner. See the ``Content Encoding Profiles`` section
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   404
for more.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   405
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   406
In the absence of this frame on a stream, it is assumed the stream is
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   407
using the ``identity`` content encoding.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   408
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   409
The following flag values are defined for this frame type:
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   410
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   411
0x01
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   412
   Data continuation. When set, an additional frame containing more encoding
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   413
   settings immediately follows.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   414
0x02
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   415
   End of data. When set, the encoding settings data has been completely
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   416
   sent.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   417
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   418
The ``0x01`` flag is mutually exclusive with the ``0x02`` flag.
37288
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   419
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   420
Stream States and Flags
39558
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
   421
=======================
37288
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   422
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   423
Streams can be in two states: *open* and *closed*. An *open* stream
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   424
is active and frames attached to that stream could arrive at any time.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   425
A *closed* stream is not active. If a frame attached to a *closed*
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   426
stream arrives, that frame MUST have an appropriate stream flag
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   427
set indicating beginning of stream. All streams are in the *closed*
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   428
state by default.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   429
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   430
The ``Stream Flags`` field denotes a set of bit flags for defining
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   431
the relationship of this frame within a stream. The following flags
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   432
are defined:
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   433
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   434
0x01
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   435
   Beginning of stream. The first frame in the stream MUST set this
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   436
   flag. When received, the ``Stream ID`` this frame is attached to
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   437
   becomes ``open``.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   438
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   439
0x02
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   440
   End of stream. The last frame in a stream MUST set this flag. When
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   441
   received, the ``Stream ID`` this frame is attached to becomes
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   442
   ``closed``. Any content encoding context associated with this stream
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   443
   can be destroyed after processing the payload of this frame.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   444
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   445
0x04
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   446
   Apply content encoding. When set, any content encoding settings
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   447
   defined by the stream should be applied when attempting to read
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   448
   the frame. When not set, the frame payload isn't encoded.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   449
40125
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   450
TODO consider making stream opening and closing communicated via
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   451
explicit frame types (e.g. a "stream state change" frame) rather than
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   452
flags on all frames. This would make stream state changes more explicit,
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   453
as they could only occur on specific frame types.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   454
37288
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   455
Streams
39558
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
   456
=======
37288
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   457
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   458
Streams - along with ``Request IDs`` - facilitate grouping of frames.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   459
But the purpose of each is quite different and the groupings they
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   460
constitute are independent.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   461
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   462
A ``Request ID`` is essentially a tag. It tells you which logical
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   463
request a frame is associated with.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   464
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   465
A *stream* is a sequence of frames grouped for the express purpose
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   466
of applying a stateful encoding or for denoting sub-groups of frames.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   467
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   468
Unlike ``Request ID``s which span the request and response, a stream
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   469
is unidirectional and stream IDs are independent from client to
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   470
server.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   471
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   472
There is no strict hierarchical relationship between ``Request IDs``
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   473
and *streams*. A stream can contain frames having multiple
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   474
``Request IDs``. Frames belonging to the same ``Request ID`` can
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   475
span multiple streams.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   476
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   477
One goal of streams is to facilitate content encoding. A stream can
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   478
define an encoding to be applied to frame payloads. For example, the
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   479
payload transmitted over the wire may contain output from a
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   480
zstandard compression operation and the receiving end may decompress
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   481
that payload to obtain the original data.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   482
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   483
The other goal of streams is to facilitate concurrent execution. For
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   484
example, a server could spawn 4 threads to service a request that can
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   485
be easily parallelized. Each of those 4 threads could write into its
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   486
own stream. Those streams could then in turn be delivered to 4 threads
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   487
on the receiving end, with each thread consuming its stream in near
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   488
isolation. The *main* thread on both ends merely does I/O and
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   489
encodes/decodes frame headers: the bulk of the work is done by worker
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   490
threads.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   491
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   492
In addition, since content encoding is defined per stream, each
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   493
*worker thread* could perform potentially CPU bound work concurrently
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   494
with other threads. This approach of applying encoding at the
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   495
sub-protocol / stream level eliminates a potential resource constraint
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   496
on the protocol stream as a whole (it is common for the throughput of
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   497
a compression engine to be smaller than the throughput of a network).
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   498
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   499
Having multiple streams - each with their own encoding settings - also
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   500
facilitates the use of advanced data compression techniques. For
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   501
example, a transmitter could see that it is generating data faster
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   502
and slower than the receiving end is consuming it and adjust its
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   503
compression settings to trade CPU for compression ratio accordingly.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   504
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   505
While streams can define a content encoding, not all frames within
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   506
that stream must use that content encoding. This can be useful when
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   507
data is being served from caches and being derived dynamically. A
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   508
cache could pre-compressed data so the server doesn't have to
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   509
recompress it. The ability to pick and choose which frames are
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   510
compressed allows servers to easily send data to the wire without
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   511
involving potentially expensive encoding overhead.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   512
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   513
Content Encoding Profiles
39558
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
   514
=========================
37288
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   515
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   516
Streams can have named content encoding *profiles* associated with
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   517
them. A profile defines a shared understanding of content encoding
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   518
settings and behavior.
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   519
40125
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   520
Profiles are described in the following sections.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   521
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   522
identity
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   523
--------
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   524
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   525
The ``identity`` profile is a no-op encoding: the encoded bytes are
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   526
exactly the input bytes.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   527
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   528
This profile MUST be supported by all peers.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   529
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   530
In the absence of an identified profile, the ``identity`` profile is
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   531
assumed.
37288
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   532
40125
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   533
zstd-8mb
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   534
--------
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   535
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   536
Zstandard encoding (RFC 8478). Zstandard is a fast and effective lossless
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   537
compression format.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   538
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   539
This profile allows decompressor window sizes of up to 8 MB.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   540
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   541
zlib
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   542
----
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   543
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   544
zlib compressed data (RFC 1950). zlib is a widely-used and supported
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   545
lossless compression format.
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   546
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   547
It isn't as fast as zstandard and it is recommended to use zstandard instead,
e2fe1074024c wireprotov2: update stream encoding specification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40022
diff changeset
   548
if possible.
37288
9bfcbe4f4745 wireproto: add streams to frame-based protocol
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37129
diff changeset
   549
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   550
Command Protocol
39558
b0e0db1565d1 internals: extract frame-based protocol docs to own document
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39439
diff changeset
   551
================
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   552
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   553
A client can request that a remote run a command by sending it
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   554
frames defining that command. This logical stream is composed of
37292
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   555
1 or more ``Command Request`` frames and and 0 or more ``Command Data``
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   556
frames.
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   557
37057
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   558
All frames composing a single command request MUST be associated with
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   559
the same ``Request ID``.
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   560
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   561
Clients MAY send additional command requests without waiting on the
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   562
response to a previous command request. If they do so, they MUST ensure
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   563
that the ``Request ID`` field of outbound frames does not conflict
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   564
with that of an active ``Request ID`` whose response has not yet been
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   565
fully received.
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   566
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   567
Servers MAY respond to commands in a different order than they were
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   568
sent over the wire. Clients MUST be prepared to deal with this. Servers
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   569
also MAY start executing commands in a different order than they were
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   570
received, or MAY execute multiple commands concurrently.
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   571
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   572
If there is a dependency between commands or a race condition between
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   573
commands executing (e.g. a read-only command that depends on the results
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   574
of a command that mutates the repository), then clients MUST NOT send
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   575
frames issuing a command until a response to all dependent commands has
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   576
been received.
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   577
TODO think about whether we should express dependencies between commands
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   578
to avoid roundtrip latency.
2ec1fb9de638 wireproto: add request IDs to frames
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37055
diff changeset
   579
37292
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   580
A command is defined by a command name, 0 or more command arguments,
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   581
and optional command data.
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   582
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   583
Arguments are the recommended mechanism for transferring fixed sets of
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   584
parameters to a command. Data is appropriate for transferring variable
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   585
data. Thinking in terms of HTTP, arguments would be headers and data
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   586
would be the message body.
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   587
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   588
It is recommended for servers to delay the dispatch of a command
37292
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   589
until all argument have been received. Servers MAY impose limits on the
3d0e2cd86e05 wireproto: use CBOR for command requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37291
diff changeset
   590
maximum argument size.
37051
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   591
TODO define failure mechanism.
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   592
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   593
Servers MAY dispatch to commands immediately once argument data
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   594
is available or delay until command data is received in full.
40206e227412 wireproto: define and implement protocol for issuing requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37050
diff changeset
   595
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   596
Once a ``Command Request`` frame is sent, a client must be prepared to
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   597
receive any of the following frames associated with that request:
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   598
``Command Response``, ``Error Response``, ``Human Output Side-Channel``,
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   599
``Progress Update``.
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   600
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   601
The *main* response for a command will be in ``Command Response`` frames.
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   602
The payloads of these frames consist of 1 or more CBOR encoded values.
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   603
The first CBOR value on the first ``Command Response`` frame is special
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   604
and denotes the overall status of the command. This CBOR map contains
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   605
the following bytestring keys:
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   606
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   607
status
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   608
   (bytestring) A well-defined message containing the overall status of
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   609
   this command request. The following values are defined:
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   610
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   611
   ok
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   612
      The command was received successfully and its response follows.
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   613
   error
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   614
      There was an error processing the command. More details about the
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   615
      error are encoded in the ``error`` key.
40022
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   616
   redirect
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   617
      The response for this command is available elsewhere. Details on
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   618
      where are in the ``location`` key.
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   619
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   620
error (optional)
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   621
   A map containing information about an encountered error. The map has the
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   622
   following keys:
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   623
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   624
   message
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   625
      (array of maps) A message describing the error. The message uses the
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
   626
      same format as those in the ``Human Output Side-Channel`` frame.
39559
07b58266bce3 wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39558
diff changeset
   627
40022
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   628
location (optional)
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   629
   (map) Presence indicates that a *content redirect* has occurred. The map
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   630
   provides the external location of the content.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   631
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   632
   This map contains the following bytestring keys:
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   633
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   634
   url
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   635
      (bytestring) URL from which this content may be requested.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   636
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   637
   mediatype
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   638
      (bytestring) The media type for the fetched content. e.g.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   639
      ``application/mercurial-*``.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   640
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   641
      In some transports, this value is also advertised by the transport.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   642
      e.g. as the ``Content-Type`` HTTP header.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   643
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   644
   size (optional)
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   645
      (unsigned integer) Total size of remote object in bytes. This is
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   646
      the raw size of the entity that will be fetched, minus any
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   647
      non-Mercurial protocol encoding (e.g. HTTP content or transfer
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   648
      encoding.)
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   649
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   650
   fullhashes (optional)
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   651
      (array of arrays) Content hashes for the entire payload. Each entry
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   652
      is an array of bytestrings containing the hash name and the hash value.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   653
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   654
   fullhashseed (optional)
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   655
      (bytestring) Optional seed value to feed into hasher for full content
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   656
      hash verification.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   657
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   658
   serverdercerts (optional)
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   659
      (array of bytestring) DER encoded x509 certificates for the server. When
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   660
      defined, clients MAY validate that the x509 certificate on the target
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   661
      server exactly matches the certificate used here.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   662
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   663
   servercadercerts (optional)
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   664
      (array of bytestring) DER encoded x509 certificates for the certificate
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   665
      authority of the target server. When defined, clients MAY validate that
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   666
      the x509 on the target server was signed by CA certificate in this set.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   667
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   668
   # TODO support for giving client an x509 certificate pair to be used as a
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   669
   # client certificate.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   670
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   671
   # TODO support common authentication mechanisms (e.g. HTTP basic/digest
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   672
   # auth).
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   673
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   674
   # TODO support custom authentication mechanisms. This likely requires
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   675
   # server to advertise required auth mechanism so client can filter.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   676
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   677
   # TODO support chained hashes. e.g. hash for each 1MB segment so client
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   678
   # can iteratively validate data without having to consume all of it first.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   679
39559
07b58266bce3 wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39558
diff changeset
   680
TODO formalize when error frames can be seen and how errors can be
07b58266bce3 wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39558
diff changeset
   681
recognized midway through a command response.
40022
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   682
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   683
Content Redirects
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   684
=================
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   685
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   686
Servers have the ability to respond to ANY command request with a
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   687
*redirect* to another location. Such a response is referred to as a *redirect
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   688
response*. (This feature is conceptually similar to HTTP redirects, but is
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   689
more powerful.)
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   690
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   691
A *redirect response* MUST ONLY be issued if the client advertises support
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   692
for a redirect *target*.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   693
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   694
A *redirect response* MUST NOT be issued unless the client advertises support
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   695
for one.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   696
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   697
Clients advertise support for *redirect responses* after looking at the server's
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   698
*capabilities* data, which is fetched during initial server connection
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   699
handshake. The server's capabilities data advertises named *targets* for
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   700
potential redirects.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   701
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   702
Each target is described by a protocol name, connection and protocol features,
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   703
etc. The server also advertises target-agnostic redirect settings, such as
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   704
which hash algorithms are supported for content integrity checking. (See
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   705
the documentation for the *capabilities* command for more.)
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   706
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   707
Clients examine the set of advertised redirect targets for compatibility.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   708
When sending a command request, the client advertises the set of redirect
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   709
target names it is willing to follow, along with some other settings influencing
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   710
behavior.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   711
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   712
For example, say the server is advertising a ``cdn`` redirect target that
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   713
requires SNI and TLS 1.2. If the client supports those features, it will
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   714
send command requests stating that the ``cdn`` target is acceptable to use.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   715
But if the client doesn't support SNI or TLS 1.2 (or maybe it encountered an
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   716
error using this target from a previous request), then it omits this target
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   717
name.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   718
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   719
If the client advertises support for a redirect target, the server MAY
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   720
substitute the normal, inline response data for a *redirect response* -
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   721
one where the initial CBOR map has a ``status`` key with value ``redirect``.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   722
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   723
The *redirect response* at a minimum advertises the URL where the response
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   724
can be retrieved.
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   725
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   726
The *redirect response* MAY also advertise additional details about that
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   727
content and how to retrieve it. Notably, the response may contain the
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   728
x509 public certificates for the server being redirected to or the
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   729
certificate authority that signed that server's certificate. Unless the
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   730
client has existing settings that offer stronger trust validation than what
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   731
the server advertises, the client SHOULD use the server-provided certificates
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   732
when validating the connection to the remote server in place of any default
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   733
connection verification checks. This is because certificates coming from
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   734
the server SHOULD establish a stronger chain of trust than what the default
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   735
certification validation mechanism in most environments provides. (By default,
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   736
certificate validation ensures the signer of the cert chains up to a set of
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   737
trusted root certificates. And if an explicit certificate or CA certificate
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   738
is presented, that greadly reduces the set of certificates that will be
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   739
recognized as valid, thus reducing the potential for a "bad" certificate
33eb670e2834 wireprotov2: define semantics for content redirects
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39559
diff changeset
   740
to be used and trusted.)