Patchwork D2829: hgweb: port to new response API

login
register
mail settings
Submitter phabricator
Date March 12, 2018, 9:43 p.m.
Message ID <c11b7886fcacf271ea50e790fa78980e@localhost.localdomain>
Download mbox | patch
Permalink /patch/29404/
State Not Applicable
Headers show

Comments

phabricator - March 12, 2018, 9:43 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGc1de7efca574: hgweb: port to new response API (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2829?vs=6895&id=6960

REVISION DETAIL
  https://phab.mercurial-scm.org/D2829

AFFECTED FILES
  mercurial/hgweb/hgwebdir_mod.py

CHANGE DETAILS




To: indygreg, #hg-reviewers, durin42
Cc: mercurial-devel

Patch

diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py
+++ b/mercurial/hgweb/hgwebdir_mod.py
@@ -15,22 +15,23 @@ 
 
 from .common import (
     ErrorResponse,
-    HTTP_NOT_FOUND,
     HTTP_SERVER_ERROR,
     cspvalues,
     get_contact,
     get_mtime,
     ismember,
     paritygen,
     staticfile,
+    statusmessage,
 )
 
 from .. import (
     configitems,
     encoding,
     error,
     hg,
     profiling,
+    pycompat,
     scmutil,
     templater,
     ui as uimod,
@@ -442,12 +443,14 @@ 
                 return self.makeindex(req, res, tmpl, subdir)
 
             # prefixes not found
-            wsgireq.respond(HTTP_NOT_FOUND, ctype)
-            return tmpl("notfound", repo=virtual)
+            res.status = '404 Not Found'
+            res.setbodygen(tmpl('notfound', repo=virtual))
+            return res.sendresponse()
 
-        except ErrorResponse as err:
-            wsgireq.respond(err, ctype)
-            return tmpl('error', error=err.message or '')
+        except ErrorResponse as e:
+            res.status = statusmessage(e.code, pycompat.bytestr(e))
+            res.setbodygen(tmpl('error', error=e.message or ''))
+            return res.sendresponse()
         finally:
             tmpl = None