aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/protocol2/http.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-08-15 16:26:12 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-08-15 16:26:12 +0200
commit0dd243c5e42950de9c8b1193ba9dbdd2d0414a45 (patch)
tree8e0ac457f60fd3775c797da8d5eab78ee53aa21a /libmproxy/protocol2/http.py
parent747699b126ab5788aca4541c9c9b4608611e7efa (diff)
downloadmitmproxy-0dd243c5e42950de9c8b1193ba9dbdd2d0414a45.tar.gz
mitmproxy-0dd243c5e42950de9c8b1193ba9dbdd2d0414a45.tar.bz2
mitmproxy-0dd243c5e42950de9c8b1193ba9dbdd2d0414a45.zip
various fixes
Diffstat (limited to 'libmproxy/protocol2/http.py')
-rw-r--r--libmproxy/protocol2/http.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/libmproxy/protocol2/http.py b/libmproxy/protocol2/http.py
index 1e774648..7adeb419 100644
--- a/libmproxy/protocol2/http.py
+++ b/libmproxy/protocol2/http.py
@@ -5,7 +5,6 @@ from ..exceptions import InvalidCredentials, HttpException, ProtocolException
from .layer import Layer, ServerConnectionMixin
from libmproxy import utils
from .messages import ChangeServer, Connect, Reconnect, Kill
-from .http_proxy import HttpProxy, HttpUpstreamProxy
from libmproxy.protocol import KILL
from libmproxy.protocol.http import HTTPFlow
@@ -66,13 +65,18 @@ def make_connect_response(httpversion):
)
-class HttpLayer(Layer, ServerConnectionMixin):
+class HttpLayer(Layer):
+
"""
HTTP 1 Layer
"""
def __init__(self, ctx):
super(HttpLayer, self).__init__(ctx)
+
+ # FIXME: Imports
+ from .http_proxy import HttpProxy, HttpUpstreamProxy
+
if any(isinstance(l, HttpProxy) for l in self.layers):
self.mode = "regular"
elif any(isinstance(l, HttpUpstreamProxy) for l in self.layers):
@@ -199,7 +203,7 @@ class HttpLayer(Layer, ServerConnectionMixin):
self.send_to_server(flow.request)
flow.response = HTTP1.read_response(
- self.server_conn.protocol,
+ self.server_conn,
flow.request.method,
body_size_limit=self.config.body_size_limit,
include_body=False,
@@ -215,6 +219,7 @@ class HttpLayer(Layer, ServerConnectionMixin):
flow.response.content = CONTENT_MISSING
else:
flow.response.content = HTTP1.read_http_body(
+ self.server_conn,
flow.response.headers,
self.config.body_size_limit,
flow.request.method,
@@ -303,7 +308,7 @@ class HttpLayer(Layer, ServerConnectionMixin):
expected_request_forms = {
"regular": ("absolute",), # an authority request would already be handled.
"upstream": ("authority", "absolute"),
- "transparent": ("regular",)
+ "transparent": ("relative",)
}
allowed_request_forms = expected_request_forms[self.mode]
@@ -314,6 +319,9 @@ class HttpLayer(Layer, ServerConnectionMixin):
self.send_to_client(make_error_response(400, err_message))
raise HttpException(err_message)
+ if self.mode == "regular":
+ request.form_out = "relative"
+
def authenticate(self, request):
if self.config.authenticator:
if self.config.authenticator.authenticate(request.headers):
@@ -327,10 +335,10 @@ class HttpLayer(Layer, ServerConnectionMixin):
raise InvalidCredentials("Proxy Authentication Required")
def send_to_server(self, message):
- self.server_conn.wfile.wrie(message)
+ self.server_conn.send(HTTP1.assemble(message))
+
def send_to_client(self, message):
# FIXME
# - possibly do some http2 stuff here
- # - fix message assembly.
- self.client_conn.wfile.write(message)
+ self.client_conn.send(HTTP1.assemble(message))