This is an archive of the discontinued Mercurial Phabricator instance.

hgweb: create dedicated type for WSGI responses
ClosedPublic

Authored by indygreg on Mar 9 2018, 11:53 PM.

Details

Summary

We have refactored the request side of WSGI processing into a dedicated
type. Now let's do the same thing for the response side.

We invent a `wsgiresponse` type. It takes an instance of a
request (for consulation) and the WSGI application's "start_response"
handler.

The type basically allows setting the HTTP status line, response
headers, and the response body.

The WSGI application calls sendresponse() to start sending output.
Output is emitted as a generator to be fed through the WSGI application.
According to PEP 3333, this is the preferred way for output to be
transmitted. (Our legacy `wsgirequest` exposed a write() to send
data. We do not wish to support this API because it isn't recommended
by PEP 3333.)

The wire protocol code has been ported to use the new API.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

indygreg created this revision.Mar 9 2018, 11:53 PM
indygreg edited the summary of this revision. (Show Details)Mar 10 2018, 3:03 PM
indygreg updated this revision to Diff 6837.
durin42 accepted this revision.Mar 12 2018, 5:02 PM
This revision is now accepted and ready to land.Mar 12 2018, 5:02 PM
This revision was automatically updated to reflect the committed changes.