Mercurial > public > mercurial-scm > hg
diff mercurial/hgweb/hgwebdir_mod.py @ 36911:f0a851542a05
hgweb: remove wsgirequest (API)
Good riddance.
.. api::
The old ``wsgirequest`` class for handling everything WSGI in hgweb
has been replaced by separate request and response types. Various
high-level functions in the hgweb WSGI applications now receive
these new types as arguments instead of the old ``wsgirequest``
type.
Differential Revision: https://phab.mercurial-scm.org/D2832
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 11 Mar 2018 16:29:54 -0700 |
parents | cd6ae9ab7bd8 |
children | 6ff6e1d6b5b8 |
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py Sat Mar 10 15:24:24 2018 +0530 +++ b/mercurial/hgweb/hgwebdir_mod.py Sun Mar 11 16:29:54 2018 -0700 @@ -348,19 +348,18 @@ def __call__(self, env, respond): baseurl = self.ui.config('web', 'baseurl') - wsgireq = requestmod.wsgirequest(env, respond, altbaseurl=baseurl) - return self.run_wsgi(wsgireq) + req = requestmod.parserequestfromenv(env, altbaseurl=baseurl) + res = requestmod.wsgiresponse(req, respond) - def run_wsgi(self, wsgireq): + return self.run_wsgi(req, res) + + def run_wsgi(self, req, res): profile = self.ui.configbool('profiling', 'enabled') with profiling.profile(self.ui, enabled=profile): - for r in self._runwsgi(wsgireq): + for r in self._runwsgi(req, res): yield r - def _runwsgi(self, wsgireq): - req = wsgireq.req - res = wsgireq.res - + def _runwsgi(self, req, res): try: self.refresh() @@ -423,13 +422,13 @@ if real: # Re-parse the WSGI environment to take into account our # repository path component. - wsgireq.req = requestmod.parserequestfromenv( - wsgireq.env, wsgireq.req.bodyfh, reponame=virtualrepo, + req = requestmod.parserequestfromenv( + req.rawenv, reponame=virtualrepo, altbaseurl=self.ui.config('web', 'baseurl')) try: # ensure caller gets private copy of ui repo = hg.repository(self.ui.copy(), real) - return hgweb_mod.hgweb(repo).run_wsgi(wsgireq) + return hgweb_mod.hgweb(repo).run_wsgi(req, res) except IOError as inst: msg = encoding.strtolocal(inst.strerror) raise ErrorResponse(HTTP_SERVER_ERROR, msg)