aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod/language/__init__.py
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2015-06-11 16:13:22 +0200
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2015-06-15 15:51:01 +0200
commita0d8afd0fcc3c678da0dc956c5a80d4e07d5ac3e (patch)
treecf3b842c1ad8f7a75d6eb2ffa8063b5385407b5a /libpathod/language/__init__.py
parent30fbf57e4b72e3947c323d98aee7b2d44663e33c (diff)
downloadmitmproxy-a0d8afd0fcc3c678da0dc956c5a80d4e07d5ac3e.tar.gz
mitmproxy-a0d8afd0fcc3c678da0dc956c5a80d4e07d5ac3e.tar.bz2
mitmproxy-a0d8afd0fcc3c678da0dc956c5a80d4e07d5ac3e.zip
http2: add request-response to pathod
Diffstat (limited to 'libpathod/language/__init__.py')
-rw-r--r--libpathod/language/__init__.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/libpathod/language/__init__.py b/libpathod/language/__init__.py
index ae9a8c76..10050bf8 100644
--- a/libpathod/language/__init__.py
+++ b/libpathod/language/__init__.py
@@ -19,7 +19,7 @@ def expand(msg):
yield msg
-def parse_pathod(s):
+def parse_pathod(s, use_http2=False):
"""
May raise ParseException
"""
@@ -28,12 +28,17 @@ def parse_pathod(s):
except UnicodeError:
raise exceptions.ParseException("Spec must be valid ASCII.", 0, 0)
try:
- reqs = pp.Or(
- [
+ if use_http2:
+ expressions = [
+ # http2.Frame.expr(),
+ http2.Response.expr(),
+ ]
+ else:
+ expressions = [
websockets.WebsocketFrame.expr(),
http.Response.expr(),
]
- ).parseString(s, parseAll=True)
+ reqs = pp.Or(expressions).parseString(s, parseAll=True)
except pp.ParseException as v:
raise exceptions.ParseException(v.msg, v.line, v.col)
return itertools.chain(*[expand(i) for i in reqs])
@@ -55,7 +60,6 @@ def parse_pathoc(s, use_http2=False):
websockets.WebsocketClientFrame.expr(),
http.Request.expr(),
]
-
reqs = pp.OneOrMore(pp.Or(expressions)).parseString(s, parseAll=True)
except pp.ParseException as v:
raise exceptions.ParseException(v.msg, v.line, v.col)