This is an archive of the discontinued Mercurial Phabricator instance.

wireproto: buffer output frames when in half duplex mode
ClosedPublic

Authored by indygreg on Mar 14 2018, 12:43 PM.

Details

Summary

Previously, when told that a response was ready, the server reactor
would instruct the caller to send frames immediately. This was OK
as an initial implementation. But it would not work for half-duplex
connections where the sender can't receive until all data has been
transmitted - such as httplib based clients.

In this commit, we teach the reactor that output frames should
be buffered until end of input is seen. This required a new
event to inform the reactor of end of input. The result from that
event will instruct the consumer to send all buffered frames.

The HTTP server is buffered by default.

This change effectively hides the complexity of buffering within
the reactor so that transports need not be concerned about it.
This helps keep the transports "dumb" and will make implementing
multiple requests-responses per atomic exchange (like an HTTP
request) much simpler.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Mar 14 2018, 12:43 PM
indygreg updated this revision to Diff 7144.Mar 19 2018, 7:59 PM
durin42 added inline comments.
mercurial/wireprotoserver.py
418–422

Recent RFCs explicitly disallow early responses with a 2xx series status code. Probably not worth pursuing.

durin42 accepted this revision.Mar 21 2018, 9:32 PM
This revision is now accepted and ready to land.Mar 21 2018, 9:32 PM
This revision was automatically updated to reflect the committed changes.