Dolda2000 GitWeb
/
wrw.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d1e3dec
)
Added a function for handling errors coming externally.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Sat, 11 Jan 2014 04:46:06 +0000
(
05:46
+0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Sat, 11 Jan 2014 04:46:06 +0000
(
05:46
+0100)
wrw/dispatch.py
patch
|
blob
|
blame
|
history
diff --git
a/wrw/dispatch.py
b/wrw/dispatch.py
index
f0326cb
..
666d7a7
100644
(file)
--- a/
wrw/dispatch.py
+++ b/
wrw/dispatch.py
@@
-55,3
+55,15
@@
def handleenv(env, startreq, handler):
return proto.simpleerror(env, startreq, 400, "Bad Request", "Request must include Host header.")
r = req.origrequest(env)
return handle(r, startreq, handler)
+
+def exterror(env, startreq):
+ def handler(req):
+ import resp
+ code = 404
+ if "Response-Code" in req.ihead:
+ try:
+ code = int(req.ihead["Response-Code"])
+ except ValueError:
+ pass
+ raise resp.httperror(code)
+ return handleenv(env, startreq, handler)