diff options
author | Aldo Cortesi <aldo@corte.si> | 2016-10-19 12:08:05 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-19 12:08:05 +1300 |
commit | 8c888a58b96687672f23cf2215a9cf90f58f288b (patch) | |
tree | fe5946f7e82ff9328a8cff0b1ad6a4c660a1b742 /pathod/language/http.py | |
parent | 8b51af16762e333ebeacff1f067415e9d38a433c (diff) | |
parent | 87629586ae5add2d605b55e65cebc1e144c612d9 (diff) | |
download | mitmproxy-8c888a58b96687672f23cf2215a9cf90f58f288b.tar.gz mitmproxy-8c888a58b96687672f23cf2215a9cf90f58f288b.tar.bz2 mitmproxy-8c888a58b96687672f23cf2215a9cf90f58f288b.zip |
Merge pull request #1628 from cortesi/webapp
Web apps to addons
Diffstat (limited to 'pathod/language/http.py')
-rw-r--r-- | pathod/language/http.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/pathod/language/http.py b/pathod/language/http.py index 5d2ff54d..32f990bb 100644 --- a/pathod/language/http.py +++ b/pathod/language/http.py @@ -2,6 +2,7 @@ import abc import pyparsing as pp +from netlib.http import url import netlib.websockets from netlib.http import status_codes, user_agents from . import base, exceptions, actions, message @@ -318,7 +319,7 @@ class Request(_HTTPMessage): ) ) if not self.raw: - if not get_header("Content-Length", self.headers): + if not get_header(b"Content-Length", self.headers): if self.body: length = sum( len(i) for i in self.body.values(settings) @@ -330,11 +331,21 @@ class Request(_HTTPMessage): ) ) if settings.request_host: - if not get_header("Host", self.headers): + if not get_header(b"Host", self.headers): + h = settings.request_host + if self.path: + path = b"".join(self.path.values({})).decode( + "ascii", errors="ignore" + ) + try: + _, h, _, _ = url.parse(path) + h = h.decode("ascii", errors="ignore") + except ValueError: + pass tokens.append( Header( base.TokValueLiteral("Host"), - base.TokValueLiteral(settings.request_host) + base.TokValueLiteral(h) ) ) intermediate = self.__class__(tokens) |