Mercurial > public > mercurial-scm > hg
comparison mercurial/wireprototypes.py @ 40025:b099e6032f38
wireprotov2: server support for sending content redirects
A "content redirect" can be sent in place of inline response content.
In terms of code, we model a content redirect as a special type of
response object holding the attributes describing that redirect.
Sending a content redirect thus becomes as simple as the object
emission layer sending an instance of that type. A cacher using
externally-addressable content storage could replace the outgoing
object stream with an object advertising its location.
The bulk of the code in this commit is teaching the output layer
which handles the object stream to recognize alternate location
objects. The rules are that if an alternate location object is
present, it must be the first and only object in the object stream.
Otherwise the server emits an error.
Differential Revision: https://phab.mercurial-scm.org/D4777
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 26 Sep 2018 18:07:55 -0700 |
parents | c537144fdbef |
children | f7011b44d205 |
comparison
equal
deleted
inserted
replaced
40024:86b22a4cfab1 | 40025:b099e6032f38 |
---|---|
366 Commands typically emit Python objects that are encoded and sent over the | 366 Commands typically emit Python objects that are encoded and sent over the |
367 wire. If commands emit an object of this type, the encoding step is bypassed | 367 wire. If commands emit an object of this type, the encoding step is bypassed |
368 and the content from this object is used instead. | 368 and the content from this object is used instead. |
369 """ | 369 """ |
370 data = attr.ib() | 370 data = attr.ib() |
371 | |
372 @attr.s | |
373 class alternatelocationresponse(object): | |
374 """Represents a response available at an alternate location. | |
375 | |
376 Instances are sent in place of actual response objects when the server | |
377 is sending a "content redirect" response. | |
378 | |
379 Only compatible with wire protocol version 2. | |
380 """ | |
381 url = attr.ib() | |
382 mediatype = attr.ib() | |
383 size = attr.ib(default=None) | |
384 fullhashes = attr.ib(default=None) | |
385 fullhashseed = attr.ib(default=None) | |
386 serverdercerts = attr.ib(default=None) | |
387 servercadercerts = attr.ib(default=None) |