aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-06-24 18:38:22 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-06-24 18:38:22 +1200
commit2ac84be7cb0e4a17fd39c6155074a37161662593 (patch)
treefc66771b1fb313d6aa121484b140adacc9c831b8 /libpathod
parentf8622ea914b506013625c539388349d53b4a7e58 (diff)
downloadmitmproxy-2ac84be7cb0e4a17fd39c6155074a37161662593.tar.gz
mitmproxy-2ac84be7cb0e4a17fd39c6155074a37161662593.tar.bz2
mitmproxy-2ac84be7cb0e4a17fd39c6155074a37161662593.zip
Add Path specification to request parser.
Diffstat (limited to 'libpathod')
-rw-r--r--libpathod/rparse.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/libpathod/rparse.py b/libpathod/rparse.py
index 50ae9804..af0f9671 100644
--- a/libpathod/rparse.py
+++ b/libpathod/rparse.py
@@ -290,6 +290,20 @@ class Body:
return e.setParseAction(lambda x: klass(*x))
+class Path:
+ def __init__(self, value):
+ self.value = value
+
+ def accept(self, settings, r):
+ r.path = self.value.get_generator(settings)
+
+ @classmethod
+ def expr(klass):
+ e = Value.copy()
+ return e.setParseAction(lambda x: klass(*x))
+
+
+
class Method:
methods = [
"get",
@@ -416,8 +430,10 @@ class Request:
ShortcutContentType,
)
version = "HTTP/1.1"
- body = LiteralGenerator("")
def __init__(self):
+ self.method = None
+ self.path = None
+ self.body = LiteralGenerator("")
self.headers = []
self.actions = []
@@ -428,6 +444,8 @@ class Request:
resp = pp.And(
[
Method.expr(),
+ pp.Literal(":").suppress(),
+ Path.expr(),
pp.ZeroOrMore(pp.Literal(":").suppress() + atom)
]
)