39
39
deserialises bytes into the structured data that requests and responses
42
Version one of the protocol (for requests and responses) is described by::
45
RESPONSE := MESSAGE_V1
46
MESSAGE_V1 := ARGS BODY
48
ARGS := ARG [MORE_ARGS] NEWLINE
49
MORE_ARGS := SEP ARG [MORE_ARGS]
52
BODY := LENGTH NEWLINE BODY_BYTES TRAILER
53
LENGTH := decimal integer
54
TRAILER := "done" NEWLINE
56
That is, a tuple of arguments separated by Ctrl-A and terminated with a
57
newline, followed by length prefixed body with a constant trailer. Note
58
that although arguments are not 8-bit safe (they cannot include 0x01 or
59
0x0a bytes without breaking the protocol encoding), the body is.
61
Version two of the request protocol is::
63
REQUEST_V2 := "bzr request 2" NEWLINE MESSAGE_V1
65
Version two of the response protocol is::
67
RESPONSE_V2 := "bzr request 2" NEWLINE MESSAGE_V1
69
Future versions should follow this structure, like version two does::
71
FUTURE_MESSAGE := VERSION_STRING NEWLINE REST_OF_MESSAGE
73
This is that clients and servers can read bytes up to the first newline
74
byte to determine what version a message is.
76
For compatibility will all versions (past and future) of bzr clients,
77
servers that receive a request in an unknown protocol version should
78
respond with a single-line error terminated with 0x0a (NEWLINE), rather
79
than structured response prefixed with a version string.
81
42
Request/Response processing
82
43
---------------------------
146
107
There is also an plain file-level transport that calls remote methods to
147
108
manipulate files on the server in `bzrlib.transport.remote`.
116
Version one of the protocol (for requests and responses) is described by::
118
REQUEST := MESSAGE_V1
119
RESPONSE := MESSAGE_V1
120
MESSAGE_V1 := ARGS BODY
122
ARGS := ARG [MORE_ARGS] NEWLINE
123
MORE_ARGS := SEP ARG [MORE_ARGS]
126
BODY := LENGTH NEWLINE BODY_BYTES TRAILER
127
LENGTH := decimal integer
128
TRAILER := "done" NEWLINE
130
That is, a tuple of arguments separated by Ctrl-A and terminated with a
131
newline, followed by length prefixed body with a constant trailer. Note
132
that although arguments are not 8-bit safe (they cannot include 0x01 or
133
0x0a bytes without breaking the protocol encoding), the body is.
138
Version two of the request protocol is::
140
REQUEST_V2 := "bzr request 2" NEWLINE MESSAGE_V2
142
Version two of the response protocol is::
144
RESPONSE_V2 := "bzr request 2" NEWLINE MESSAGE_V2
146
Future versions should follow this structure, like version two does::
148
FUTURE_MESSAGE := VERSION_STRING NEWLINE REST_OF_MESSAGE
150
This is so that clients and servers can read bytes up to the first newline
151
byte to determine what version a message is.
153
For compatibility will all versions (past and future) of bzr clients,
154
servers that receive a request in an unknown protocol version should
155
respond with a single-line error terminated with 0x0a (NEWLINE), rather
156
than structured response prefixed with a version string.
158
Version two of the message protocol is::
160
MESSAGE_V2 := ARGS BODY
161
BODY_V2 := BODY | STREAMED_BODY
163
That is, a version one length-prefixed body, or a version two streamed
166
A streamed body looks a lot like HTTP's chunked encoding::
168
STREAMED_BODY := "chunked" NEWLINE CHUNKS TERMINATOR
169
CHUNKS := CHUNK [CHUNKS]
170
CHUNK := CHUNK_LENGTH CHUNK_CONTENT
171
CHUNK_LENGTH := HEX_DIGITS NEWLINE
172
CHUNK_CONTENT := bytes
174
TERMINATOR := SUCCESS_TERMINATOR | ERROR_TERMINATOR
175
SUCCESS_TERMINATOR := 'END' NEWLINE
176
ERROR_TERMINATOR := 'ERR' NEWLINE CHUNKS SUCCESS_TERMINATOR
178
That is, the body consists of a series of chunks. Each chunk starts with
179
a length prefix in hexadecimal digits, followed by an ASCII newline byte.
180
The end of the body is signaled by 'END\\n', or by 'ERR\\n' followed by
181
error args, one per chunk. Note that this allows an 8-bit clean error
184
A streamed body starts with the string "chunked" so that legacy clients
185
and servers will not mistake the first chunk as the start of a version one
191
Version 1 of the protocol was introduced in Bazaar 0.11.
193
Version 2 was introduced in Bazaar 0.16.