Show More
@@ -65,11 +65,27 b' Example HTTP requests::' | |||
|
65 | 65 | GET /repo?cmd=capabilities |
|
66 | 66 | X-HgArg-1: foo=bar&baz=hello%20world |
|
67 | 67 | |
|
68 | The request media type should be chosen based on server support. If the | |
|
69 | ``httpmediatype`` server capability is present, the client should send | |
|
70 | the newest mutually supported media type. If this capability is absent, | |
|
71 | the client must assume the server only supports the | |
|
72 | ``application/mercurial-0.1`` media type. | |
|
73 | ||
|
68 | 74 | The ``Content-Type`` HTTP response header identifies the response as coming |
|
69 | 75 | from Mercurial and can also be used to signal an error has occurred. |
|
70 | 76 | |
|
71 |
The ``application/mercurial- |
|
|
72 | response. It matches the media type sent by the client. | |
|
77 | The ``application/mercurial-*`` media types indicate a generic Mercurial | |
|
78 | data type. | |
|
79 | ||
|
80 | The ``application/mercurial-0.1`` media type is raw Mercurial data. It is the | |
|
81 | predecessor of the format below. | |
|
82 | ||
|
83 | The ``application/mercurial-0.2`` media type is compression framed Mercurial | |
|
84 | data. The first byte of the payload indicates the length of the compression | |
|
85 | format identifier that follows. Next are N bytes indicating the compression | |
|
86 | format. e.g. ``zlib``. The remaining bytes are compressed according to that | |
|
87 | compression format. The decompressed data behaves the same as with | |
|
88 | ``application/mercurial-0.1``. | |
|
73 | 89 | |
|
74 | 90 | The ``application/hg-error`` media type indicates a generic error occurred. |
|
75 | 91 | The content of the HTTP response body typically holds text describing the |
@@ -81,15 +97,19 b' type.' | |||
|
81 | 97 | Clients also accept the ``text/plain`` media type. All other media |
|
82 | 98 | types should cause the client to error. |
|
83 | 99 | |
|
100 | Behavior of media types is further described in the ``Content Negotiation`` | |
|
101 | section below. | |
|
102 | ||
|
84 | 103 | Clients should issue a ``User-Agent`` request header that identifies the client. |
|
85 | 104 | The server should not use the ``User-Agent`` for feature detection. |
|
86 | 105 | |
|
87 |
A command returning a ``string`` response issues |
|
|
88 |
``application/mercurial-0. |
|
|
89 | the raw string value. A ``Content-Length`` header is typically issued. | |
|
106 | A command returning a ``string`` response issues a | |
|
107 | ``application/mercurial-0.*`` media type and the HTTP response body contains | |
|
108 | the raw string value (after compression decoding, if used). A | |
|
109 | ``Content-Length`` header is typically issued, but not required. | |
|
90 | 110 | |
|
91 |
A command returning a ``stream`` response issues |
|
|
92 |
``application/mercurial-0. |
|
|
111 | A command returning a ``stream`` response issues a | |
|
112 | ``application/mercurial-0.*`` media type and the HTTP response is typically | |
|
93 | 113 | using *chunked transfer* (``Transfer-Encoding: chunked``). |
|
94 | 114 | |
|
95 | 115 | SSH Transport |
@@ -233,6 +253,24 b' 2006).' | |||
|
233 | 253 | This capability was introduced at the same time as the ``lookup`` |
|
234 | 254 | capability/command. |
|
235 | 255 | |
|
256 | compression | |
|
257 | ----------- | |
|
258 | ||
|
259 | Declares support for negotiating compression formats. | |
|
260 | ||
|
261 | Presence of this capability indicates the server supports dynamic selection | |
|
262 | of compression formats based on the client request. | |
|
263 | ||
|
264 | Servers advertising this capability are required to support the | |
|
265 | ``application/mercurial-0.2`` media type in response to commands returning | |
|
266 | streams. Servers may support this media type on any command. | |
|
267 | ||
|
268 | The value of the capability is a comma-delimited list of strings declaring | |
|
269 | supported compression formats. The order of the compression formats is in | |
|
270 | server-preferred order, most preferred first. | |
|
271 | ||
|
272 | This capability was introduced in Mercurial 4.1 (released February 2017). | |
|
273 | ||
|
236 | 274 | getbundle |
|
237 | 275 | --------- |
|
238 | 276 | |
@@ -252,6 +290,51 b' comma in the value, as this is reserved ' | |||
|
252 | 290 | |
|
253 | 291 | This capability was introduced in Mercurial 1.9 (released July 2011). |
|
254 | 292 | |
|
293 | httpmediatype | |
|
294 | ------------- | |
|
295 | ||
|
296 | Indicates which HTTP media types (``Content-Type`` header) the server is | |
|
297 | capable of receiving and sending. | |
|
298 | ||
|
299 | The value of the capability is a comma-delimited list of strings identifying | |
|
300 | support for media type and transmission direction. The following strings may | |
|
301 | be present: | |
|
302 | ||
|
303 | 0.1rx | |
|
304 | Indicates server support for receiving ``application/mercurial-0.1`` media | |
|
305 | types. | |
|
306 | ||
|
307 | 0.1tx | |
|
308 | Indicates server support for sending ``application/mercurial-0.1`` media | |
|
309 | types. | |
|
310 | ||
|
311 | 0.2rx | |
|
312 | Indicates server support for receiving ``application/mercurial-0.2`` media | |
|
313 | types. | |
|
314 | ||
|
315 | 0.2tx | |
|
316 | Indicates server support for sending ``application/mercurial-0.2`` media | |
|
317 | types. | |
|
318 | ||
|
319 | minrx=X | |
|
320 | Minimum media type version the server is capable of receiving. Value is a | |
|
321 | string like ``0.2``. | |
|
322 | ||
|
323 | This capability can be used by servers to limit connections from legacy | |
|
324 | clients not using the latest supported media type. However, only clients | |
|
325 | with knowledge of this capability will know to consult this value. This | |
|
326 | capability is present so the client may issue a more user-friendly error | |
|
327 | when the server has locked out a legacy client. | |
|
328 | ||
|
329 | mintx=X | |
|
330 | Minimum media type version the server is capable of sending. Value is a | |
|
331 | string like ``0.1``. | |
|
332 | ||
|
333 | Servers advertising support for the ``application/mercurial-0.2`` media type | |
|
334 | should also advertise the ``compression`` capability. | |
|
335 | ||
|
336 | This capability was introduced in Mercurial 4.1 (released February 2017). | |
|
337 | ||
|
255 | 338 | httppostargs |
|
256 | 339 | ------------ |
|
257 | 340 | |
@@ -416,6 +499,57 b' Mercurial server replies to the client-i' | |||
|
416 | 499 | not conforming to the expected command responses is assumed to be not related |
|
417 | 500 | to Mercurial and can be ignored. |
|
418 | 501 | |
|
502 | Content Negotiation | |
|
503 | =================== | |
|
504 | ||
|
505 | The wire protocol has some mechanisms to help peers determine what content | |
|
506 | types and encoding the other side will accept. Historically, these mechanisms | |
|
507 | have been built into commands themselves because most commands only send a | |
|
508 | well-defined response type and only certain commands needed to support | |
|
509 | functionality like compression. | |
|
510 | ||
|
511 | Currently, only the HTTP transport supports content negotiation at the protocol | |
|
512 | layer. | |
|
513 | ||
|
514 | HTTP requests advertise supported response formats via the ``X-HgProto-<N>`` | |
|
515 | request header, where ``<N>`` is an integer starting at 1 allowing the logical | |
|
516 | value to span multiple headers. This value consists of a list of | |
|
517 | space-delimited parameters. Each parameter denotes a feature or capability. | |
|
518 | ||
|
519 | The following parameters are defined: | |
|
520 | ||
|
521 | 0.1 | |
|
522 | Indicates the client supports receiving ``application/mercurial-0.1`` | |
|
523 | responses. | |
|
524 | ||
|
525 | 0.2 | |
|
526 | Indicates the client supports receiving ``application/mercurial-0.2`` | |
|
527 | responses. | |
|
528 | ||
|
529 | comp | |
|
530 | Indicates compression formats the client can decode. Value is a list of | |
|
531 | comma delimited strings identifying compression formats ordered from | |
|
532 | most preferential to least preferential. e.g. ``comp=zstd,zlib,none``. | |
|
533 | ||
|
534 | This parameter does not have an effect if only the ``0.1`` parameter | |
|
535 | is defined, as support for ``application/mercurial-0.2`` or greater is | |
|
536 | required to use arbitrary compression formats. | |
|
537 | ||
|
538 | If this parameter is not advertised, the server interprets this as | |
|
539 | equivalent to ``zlib,none``. | |
|
540 | ||
|
541 | Clients may choose to only send this header if the ``httpmediatype`` | |
|
542 | server capability is present, as currently all server-side features | |
|
543 | consulting this header require the client to opt in to new protocol features | |
|
544 | advertised via the ``httpmediatype`` capability. | |
|
545 | ||
|
546 | A server that doesn't receive an ``X-HgProto-<N>`` header should infer a | |
|
547 | value of ``0.1``. This is compatible with legacy clients. | |
|
548 | ||
|
549 | A server receiving a request indicating support for multiple media type | |
|
550 | versions may respond with any of the supported media types. Not all servers | |
|
551 | may support all media types on all commands. | |
|
552 | ||
|
419 | 553 | Commands |
|
420 | 554 | ======== |
|
421 | 555 |
General Comments 0
You need to be logged in to leave comments.
Login now