aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod/rparse.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-04-28 22:54:45 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-04-28 22:54:45 +1200
commitee909e265b40743479ca2f3e8b518f76c91f83f8 (patch)
treef267a1e2c3d7d23843f67794f090892b6b4d8177 /libpathod/rparse.py
parent2d989e2fbb8b87847c215a984bc8a010ce583a8e (diff)
downloadmitmproxy-ee909e265b40743479ca2f3e8b518f76c91f83f8.tar.gz
mitmproxy-ee909e265b40743479ca2f3e8b518f76c91f83f8.tar.bz2
mitmproxy-ee909e265b40743479ca2f3e8b518f76c91f83f8.zip
Add a shortcut for setting Location header.
Diffstat (limited to 'libpathod/rparse.py')
-rw-r--r--libpathod/rparse.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/libpathod/rparse.py b/libpathod/rparse.py
index 4f7cc12d..b47681cc 100644
--- a/libpathod/rparse.py
+++ b/libpathod/rparse.py
@@ -211,6 +211,26 @@ class ShortcutContentType:
return e.setParseAction(lambda x: klass(*x))
+
+class ShortcutLocation:
+ def __init__(self, value):
+ self.value = value
+
+ def mod_response(self, settings, r):
+ r.headers.append(
+ (
+ LiteralGenerator("Location"),
+ self.value.get_generator(settings)
+ )
+ )
+
+ @classmethod
+ def expr(klass):
+ e = pp.Literal("l").suppress()
+ e = e + Value
+ return e.setParseAction(lambda x: klass(*x))
+
+
class Body:
def __init__(self, value):
self.value = value
@@ -332,6 +352,7 @@ class Response:
DisconnectBefore,
DisconnectRandom,
ShortcutContentType,
+ ShortcutLocation,
)
version = "HTTP/1.1"
code = 200