This is an archive of the discontinued Mercurial Phabricator instance.

hgweb: use our forked wsgiheaders module instead of stdlib one
ClosedPublic

Authored by durin42 on Mar 13 2018, 11:30 PM.

Details

Summary

Now we use bytes for headers, rather than native strings.

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

durin42 created this revision.Mar 13 2018, 11:30 PM
indygreg requested changes to this revision.Mar 14 2018, 12:54 AM
indygreg added a subscriber: indygreg.

parsedrequest.headers is supposed to be bytes. One of the goals of this refactor was to make the WSGI code all bytes all the time. So if system strings are making their way to the new request or response objects (i.e. outside request.py), then something is wrong and we should fix that: we shouldn’t need to introduce raw literals outside of the very low level WSGI code.

This revision now requires changes to proceed.Mar 14 2018, 12:54 AM

parsedrequest.headers is supposed to be bytes. One of the goals of this refactor was to make the WSGI code all bytes all the time. So if system strings are making their way to the new request or response objects (i.e. outside request.py), then something is wrong and we should fix that: we shouldn’t need to introduce raw literals outside of the very low level WSGI code.

We're using wsgirequest.headers.Headers. Python 3's implementation insists that headers be specified as the native str type: https://github.com/python/cpython/blob/master/Lib/wsgiref/headers.py. Because of course it does. Ugh.

It looks like we'll have to implement a case insensitive + -/_ normalizing keys dict for header storage. Shouldn't be a big deal.

durin42 edited the summary of this revision. (Show Details)Apr 11 2018, 3:50 PM
durin42 retitled this revision from hgweb: str/bytes followups after indygreg's refactoring to hgweb: use our forked wsgiheaders module instead of stdlib one.
durin42 updated this revision to Diff 8009.
indygreg accepted this revision.Apr 12 2018, 11:10 AM
This revision is now accepted and ready to land.Apr 12 2018, 11:10 AM
indygreg requested changes to this revision.Apr 12 2018, 11:30 AM

This one caused an import cycle: Import cycle: mercurial.hgweb.__init__ -> mercurial.hgweb.hgweb_mod -> mercurial.hgweb.request -> mercurial.hgweb.__init__

This revision now requires changes to proceed.Apr 12 2018, 11:30 AM
durin42 updated this revision to Diff 8074.Apr 12 2018, 12:47 PM
indygreg accepted this revision.Apr 12 2018, 12:59 PM
This revision is now accepted and ready to land.Apr 12 2018, 12:59 PM
This revision was automatically updated to reflect the committed changes.