aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/har_extractor.py2
-rw-r--r--mitmproxy/models/flow.py1
-rw-r--r--mitmproxy/models/http.py22
-rw-r--r--mitmproxy/protocol/http.py16
-rw-r--r--mitmproxy/protocol/http1.py2
-rw-r--r--mitmproxy/protocol/http2.py6
-rw-r--r--mitmproxy/protocol/http_replay.py10
-rw-r--r--netlib/http/http2/connections.py8
-rw-r--r--netlib/http/request.py21
-rw-r--r--netlib/http/response.py10
-rw-r--r--pathod/pathoc.py2
-rw-r--r--test/mitmproxy/test_server.py16
-rw-r--r--test/netlib/http/http2/test_connections.py16
13 files changed, 41 insertions, 91 deletions
diff --git a/examples/har_extractor.py b/examples/har_extractor.py
index 15e1ef30..371e2282 100644
--- a/examples/har_extractor.py
+++ b/examples/har_extractor.py
@@ -143,7 +143,7 @@ def response(context, flow):
},
"response": {
"status": flow.response.status_code,
- "statusText": flow.response.msg,
+ "statusText": flow.response.reason,
"httpVersion": flow.response.http_version,
"cookies": format_cookies(flow.response.cookies),
"headers": format_headers(flow.response.headers),
diff --git a/mitmproxy/models/flow.py b/mitmproxy/models/flow.py
index 95fb2b69..45b3b5e0 100644
--- a/mitmproxy/models/flow.py
+++ b/mitmproxy/models/flow.py
@@ -28,7 +28,6 @@ class Error(stateobject.StateObject):
@type msg: str
@type timestamp: float
"""
- self.flow = None # will usually be set by the flow backref mixin
self.msg = msg
self.timestamp = timestamp or utils.timestamp()
diff --git a/mitmproxy/models/http.py b/mitmproxy/models/http.py
index 377f0731..cb11b742 100644
--- a/mitmproxy/models/http.py
+++ b/mitmproxy/models/http.py
@@ -79,18 +79,13 @@ class HTTPRequest(MessageMixin, Request):
content: Content of the request, the value is None if there is content
associated, but not present.
- form_in: The request form which mitmproxy has received. The following
- values are possible:
+ first_line_format: The request form. The following values are possible:
- - relative (GET /index.html, OPTIONS *) (covers origin form and
- asterisk form)
+ - relative (GET /index.html, OPTIONS *) (origin form or asterisk form)
- absolute (GET http://example.com:80/index.html)
- authority-form (CONNECT example.com:443)
Details: http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-25#section-5.3
- form_out: The request form which mitmproxy will send out to the
- destination
-
timestamp_start: Timestamp indicating when request transmission started
timestamp_end: Timestamp indicating when request transmission ended
@@ -109,7 +104,6 @@ class HTTPRequest(MessageMixin, Request):
content,
timestamp_start=None,
timestamp_end=None,
- form_out=None,
is_replay=False,
stickycookie=False,
stickyauth=False,
@@ -128,7 +122,6 @@ class HTTPRequest(MessageMixin, Request):
timestamp_start,
timestamp_end,
)
- self.form_out = form_out or first_line_format # FIXME remove
# Have this request's cookies been modified by sticky cookies or auth?
self.stickycookie = stickycookie
@@ -166,20 +159,9 @@ class HTTPRequest(MessageMixin, Request):
content=request.data.content,
timestamp_start=request.data.timestamp_start,
timestamp_end=request.data.timestamp_end,
- form_out=(request.form_out if hasattr(request, 'form_out') else None),
)
return req
- @property
- def form_out(self):
- warnings.warn(".form_out is deprecated, use .first_line_format instead.", DeprecationWarning)
- return self.first_line_format
-
- @form_out.setter
- def form_out(self, value):
- warnings.warn(".form_out is deprecated, use .first_line_format instead.", DeprecationWarning)
- self.first_line_format = value
-
def __hash__(self):
return id(self)
diff --git a/mitmproxy/protocol/http.py b/mitmproxy/protocol/http.py
index e58d3430..db24ca92 100644
--- a/mitmproxy/protocol/http.py
+++ b/mitmproxy/protocol/http.py
@@ -167,7 +167,7 @@ class HttpLayer(Layer):
self.validate_request(request)
# Regular Proxy Mode: Handle CONNECT
- if self.mode == "regular" and request.form_in == "authority":
+ if self.mode == "regular" and request.first_line_format == "authority":
self.handle_regular_mode_connect(request)
return
@@ -215,7 +215,7 @@ class HttpLayer(Layer):
return
# Upstream Proxy Mode: Handle CONNECT
- if flow.request.form_in == "authority" and flow.response.status_code == 200:
+ if flow.request.first_line_format == "authority" and flow.response.status_code == 200:
self.handle_upstream_mode_connect(flow.request.copy())
return
@@ -340,7 +340,7 @@ class HttpLayer(Layer):
if self.mode == "regular":
pass # only absolute-form at this point, nothing to do here.
elif self.mode == "upstream":
- if flow.request.form_in == "authority":
+ if flow.request.first_line_format == "authority":
flow.request.scheme = "http" # pseudo value
else:
# Setting request.host also updates the host header, which we want to preserve
@@ -390,7 +390,7 @@ class HttpLayer(Layer):
"""
def validate_request(self, request):
- if request.form_in == "absolute" and request.scheme != "http":
+ if request.first_line_format == "absolute" and request.scheme != "http":
raise HttpException("Invalid request scheme: %s" % request.scheme)
expected_request_forms = {
@@ -400,14 +400,14 @@ class HttpLayer(Layer):
}
allowed_request_forms = expected_request_forms[self.mode]
- if request.form_in not in allowed_request_forms:
+ if request.first_line_format not in allowed_request_forms:
err_message = "Invalid HTTP request form (expected: %s, got: %s)" % (
- " or ".join(allowed_request_forms), request.form_in
+ " or ".join(allowed_request_forms), request.first_line_format
)
raise HttpException(err_message)
- if self.mode == "regular" and request.form_in == "absolute":
- request.form_out = "relative"
+ if self.mode == "regular" and request.first_line_format == "absolute":
+ request.first_line_format = "relative"
def authenticate(self, request):
if self.config.authenticator:
diff --git a/mitmproxy/protocol/http1.py b/mitmproxy/protocol/http1.py
index a4cd8801..940a4c98 100644
--- a/mitmproxy/protocol/http1.py
+++ b/mitmproxy/protocol/http1.py
@@ -54,7 +54,7 @@ class Http1Layer(_HttpTransmissionLayer):
)
read_until_eof = http1.expected_http_body_size(flow.request, flow.response) == -1
close_connection = request_close or response_close or read_until_eof
- if flow.request.form_in == "authority" and flow.response.status_code == 200:
+ if flow.request.first_line_format == "authority" and flow.response.status_code == 200:
# Workaround for https://github.com/mitmproxy/mitmproxy/issues/313:
# Charles Proxy sends a CONNECT response with HTTP/1.0
# and no Content-Length header
diff --git a/mitmproxy/protocol/http2.py b/mitmproxy/protocol/http2.py
index eba4795e..03d4aefc 100644
--- a/mitmproxy/protocol/http2.py
+++ b/mitmproxy/protocol/http2.py
@@ -303,11 +303,11 @@ class Http2SingleStreamLayer(_HttpTransmissionLayer, threading.Thread):
port = None
if path == '*' or path.startswith("/"):
- form_in = "relative"
+ first_line_format = "relative"
elif method == 'CONNECT': # pragma: no cover
raise NotImplementedError("CONNECT over HTTP/2 is not implemented.")
else: # pragma: no cover
- form_in = "absolute"
+ first_line_format = "absolute"
# FIXME: verify if path or :host contains what we need
scheme, host, port, _ = utils.parse_url(path)
@@ -326,7 +326,7 @@ class Http2SingleStreamLayer(_HttpTransmissionLayer, threading.Thread):
data = b"".join(data)
return HTTPRequest(
- form_in,
+ first_line_format,
method,
scheme,
host,
diff --git a/mitmproxy/protocol/http_replay.py b/mitmproxy/protocol/http_replay.py
index 6316f26c..62f842ce 100644
--- a/mitmproxy/protocol/http_replay.py
+++ b/mitmproxy/protocol/http_replay.py
@@ -30,7 +30,7 @@ class RequestReplayThread(threading.Thread):
def run(self):
r = self.flow.request
- form_out_backup = r.form_out
+ first_line_format_backup = r.first_line_format
try:
self.flow.response = None
@@ -63,9 +63,9 @@ class RequestReplayThread(threading.Thread):
self.config.clientcerts,
sni=self.flow.server_conn.sni
)
- r.form_out = "relative"
+ r.first_line_format = "relative"
else:
- r.form_out = "absolute"
+ r.first_line_format= "absolute"
else:
server_address = (r.host, r.port)
server = ServerConnection(server_address, (self.config.host, 0))
@@ -75,7 +75,7 @@ class RequestReplayThread(threading.Thread):
self.config.clientcerts,
sni=self.flow.server_conn.sni
)
- r.form_out = "relative"
+ r.first_line_format = "relative"
server.wfile.write(http1.assemble_request(r))
server.wfile.flush()
@@ -102,4 +102,4 @@ class RequestReplayThread(threading.Thread):
from ..proxy.root_context import Log
self.channel.tell("log", Log(traceback.format_exc(), "error"))
finally:
- r.form_out = form_out_backup
+ r.first_line_format = first_line_format_backup
diff --git a/netlib/http/http2/connections.py b/netlib/http/http2/connections.py
index 52fa7193..f900b67c 100644
--- a/netlib/http/http2/connections.py
+++ b/netlib/http/http2/connections.py
@@ -102,15 +102,15 @@ class HTTP2Protocol(object):
port = None
if path == '*' or path.startswith("/"):
- form_in = "relative"
+ first_line_format = "relative"
elif method == 'CONNECT':
- form_in = "authority"
+ first_line_format = "authority"
if ":" in authority:
host, port = authority.split(":", 1)
else:
host = authority
else:
- form_in = "absolute"
+ first_line_format = "absolute"
# FIXME: verify if path or :host contains what we need
scheme, host, port, _ = utils.parse_url(path)
scheme = scheme.decode('ascii')
@@ -123,7 +123,7 @@ class HTTP2Protocol(object):
port = int(port)
request = Request(
- form_in,
+ first_line_format,
method.encode('ascii'),
scheme.encode('ascii'),
host.encode('ascii'),
diff --git a/netlib/http/request.py b/netlib/http/request.py
index 5bd2547e..db4901b7 100644
--- a/netlib/http/request.py
+++ b/netlib/http/request.py
@@ -358,24 +358,3 @@ class Request(Message):
def get_form_multipart(self): # pragma: no cover
warnings.warn(".get_form_multipart is deprecated, use .multipart_form instead.", DeprecationWarning)
return self.multipart_form or ODict([])
-
- @property
- def form_in(self): # pragma: no cover
- warnings.warn(".form_in is deprecated, use .first_line_format instead.", DeprecationWarning)
- return self.first_line_format
-
- @form_in.setter
- def form_in(self, form_in): # pragma: no cover
- warnings.warn(".form_in is deprecated, use .first_line_format instead.", DeprecationWarning)
- self.first_line_format = form_in
-
- @property
- def form_out(self): # pragma: no cover
- warnings.warn(".form_out is deprecated, use .first_line_format instead.", DeprecationWarning)
- return self.first_line_format
-
- @form_out.setter
- def form_out(self, form_out): # pragma: no cover
- warnings.warn(".form_out is deprecated, use .first_line_format instead.", DeprecationWarning)
- self.first_line_format = form_out
-
diff --git a/netlib/http/response.py b/netlib/http/response.py
index 4e2e6442..efd7f60a 100644
--- a/netlib/http/response.py
+++ b/netlib/http/response.py
@@ -137,13 +137,3 @@ class Response(Message):
def set_cookies(self, odict): # pragma: no cover
warnings.warn(".set_cookies is deprecated, use .cookies instead.", DeprecationWarning)
self.cookies = odict
-
- @property
- def msg(self): # pragma: no cover
- warnings.warn(".msg is deprecated, use .reason instead.", DeprecationWarning)
- return self.reason
-
- @msg.setter
- def msg(self, reason): # pragma: no cover
- warnings.warn(".msg is deprecated, use .reason instead.", DeprecationWarning)
- self.reason = reason
diff --git a/pathod/pathoc.py b/pathod/pathoc.py
index 0e6d3ca7..f55a2eda 100644
--- a/pathod/pathoc.py
+++ b/pathod/pathoc.py
@@ -425,7 +425,7 @@ class Pathoc(tcp.TCPClient):
finally:
if resp:
lg("<< %s %s: %s bytes" % (
- resp.status_code, utils.xrepr(resp.msg), len(resp.content)
+ resp.status_code, utils.xrepr(resp.reason), len(resp.content)
))
if resp.status_code in self.ignorecodes:
lg.suppress()
diff --git a/test/mitmproxy/test_server.py b/test/mitmproxy/test_server.py
index dc72f032..0d56e7ea 100644
--- a/test/mitmproxy/test_server.py
+++ b/test/mitmproxy/test_server.py
@@ -973,22 +973,22 @@ class TestProxyChainingSSLReconnect(tservers.HTTPUpstreamProxyTest):
assert not self.chain[1].tmaster.state.flows[0].response # killed
assert self.chain[1].tmaster.state.flows[1].response
- assert self.proxy.tmaster.state.flows[0].request.form_in == "authority"
- assert self.proxy.tmaster.state.flows[1].request.form_in == "relative"
+ assert self.proxy.tmaster.state.flows[0].request.first_line_format == "authority"
+ assert self.proxy.tmaster.state.flows[1].request.first_line_format == "relative"
assert self.chain[0].tmaster.state.flows[
- 0].request.form_in == "authority"
+ 0].request.first_line_format == "authority"
assert self.chain[0].tmaster.state.flows[
- 1].request.form_in == "relative"
+ 1].request.first_line_format == "relative"
assert self.chain[0].tmaster.state.flows[
- 2].request.form_in == "authority"
+ 2].request.first_line_format == "authority"
assert self.chain[0].tmaster.state.flows[
- 3].request.form_in == "relative"
+ 3].request.first_line_format == "relative"
assert self.chain[1].tmaster.state.flows[
- 0].request.form_in == "relative"
+ 0].request.first_line_format == "relative"
assert self.chain[1].tmaster.state.flows[
- 1].request.form_in == "relative"
+ 1].request.first_line_format == "relative"
req = p.request("get:'/p/418:b\"content2\"'")
diff --git a/test/netlib/http/http2/test_connections.py b/test/netlib/http/http2/test_connections.py
index c067d487..7b003067 100644
--- a/test/netlib/http/http2/test_connections.py
+++ b/test/netlib/http/http2/test_connections.py
@@ -325,7 +325,7 @@ class TestReadRequestRelative(tservers.ServerTestBase):
ssl = True
- def test_asterisk_form_in(self):
+ def test_asterisk_form(self):
c = tcp.TCPClient(("127.0.0.1", self.port))
c.connect()
c.convert_to_ssl()
@@ -334,7 +334,7 @@ class TestReadRequestRelative(tservers.ServerTestBase):
req = protocol.read_request(NotImplemented)
- assert req.form_in == "relative"
+ assert req.first_line_format == "relative"
assert req.method == "OPTIONS"
assert req.path == "*"
@@ -348,7 +348,7 @@ class TestReadRequestAbsolute(tservers.ServerTestBase):
ssl = True
- def test_absolute_form_in(self):
+ def test_absolute_form(self):
c = tcp.TCPClient(("127.0.0.1", self.port))
c.connect()
c.convert_to_ssl()
@@ -357,7 +357,7 @@ class TestReadRequestAbsolute(tservers.ServerTestBase):
req = protocol.read_request(NotImplemented)
- assert req.form_in == "absolute"
+ assert req.first_line_format == "absolute"
assert req.scheme == "http"
assert req.host == "address"
assert req.port == 22
@@ -382,13 +382,13 @@ class TestReadRequestConnect(tservers.ServerTestBase):
protocol.connection_preface_performed = True
req = protocol.read_request(NotImplemented)
- assert req.form_in == "authority"
+ assert req.first_line_format == "authority"
assert req.method == "CONNECT"
assert req.host == "address"
assert req.port == 22
req = protocol.read_request(NotImplemented)
- assert req.form_in == "authority"
+ assert req.first_line_format == "authority"
assert req.method == "CONNECT"
assert req.host == "example.com"
assert req.port == 443
@@ -417,7 +417,7 @@ class TestReadResponse(tservers.ServerTestBase):
assert resp.http_version == "HTTP/2.0"
assert resp.status_code == 200
- assert resp.msg == ''
+ assert resp.reason == ''
assert resp.headers.fields == [[b':status', b'200'], [b'etag', b'foobar']]
assert resp.content == b'foobar'
assert resp.timestamp_end
@@ -444,7 +444,7 @@ class TestReadEmptyResponse(tservers.ServerTestBase):
assert resp.stream_id == 42
assert resp.http_version == "HTTP/2.0"
assert resp.status_code == 200
- assert resp.msg == ''
+ assert resp.reason == ''
assert resp.headers.fields == [[b':status', b'200'], [b'etag', b'foobar']]
assert resp.content == b''