diff options
-rw-r--r-- | docs/features/reverseproxy.rst | 6 | ||||
-rw-r--r-- | docs/schematics/proxy-modes-flowchart.png | bin | 34635 -> 71622 bytes | |||
-rw-r--r-- | docs/schematics/proxy-modes.vsdx | bin | 190788 -> 191464 bytes | |||
-rw-r--r-- | libmproxy/console/common.py | 4 | ||||
-rw-r--r-- | libmproxy/console/help.py | 1 | ||||
-rw-r--r-- | libmproxy/protocol/http.py | 11 | ||||
-rw-r--r-- | test/test_server.py | 20 |
7 files changed, 17 insertions, 25 deletions
diff --git a/docs/features/reverseproxy.rst b/docs/features/reverseproxy.rst index 77e9327c..87065e73 100644 --- a/docs/features/reverseproxy.rst +++ b/docs/features/reverseproxy.rst @@ -3,15 +3,15 @@ Reverse Proxy ============= -In reverse proxy mode, mitmproxy accepts standard HTTP requests and forwards +In reverse proxy mode, mitmproxy accepts standard HTTP(S) requests and forwards them to the specified upstream server. This is in contrast to :ref:`upstreamproxy`, in which -mitmproxy forwards HTTP proxy requests to an upstream proxy server. +mitmproxy forwards HTTP(S) proxy requests to an upstream proxy server. ================== ===================================== command-line :option:`-R http[s]://hostname[:port]` ================== ===================================== -Here, **scheme** signifies if the proxy should use TLS to connect to the server. +Here, **http[s]** signifies if the proxy should use TLS to connect to the server. mitmproxy always accepts both encrypted and unencrypted requests and transforms them to what the server expects. diff --git a/docs/schematics/proxy-modes-flowchart.png b/docs/schematics/proxy-modes-flowchart.png Binary files differindex 716b5ee2..e9568dac 100644 --- a/docs/schematics/proxy-modes-flowchart.png +++ b/docs/schematics/proxy-modes-flowchart.png diff --git a/docs/schematics/proxy-modes.vsdx b/docs/schematics/proxy-modes.vsdx Binary files differindex c78cf8d0..0128a142 100644 --- a/docs/schematics/proxy-modes.vsdx +++ b/docs/schematics/proxy-modes.vsdx diff --git a/libmproxy/console/common.py b/libmproxy/console/common.py index 48cb0f87..1a72fa2a 100644 --- a/libmproxy/console/common.py +++ b/libmproxy/console/common.py @@ -96,6 +96,10 @@ def format_keyvals(lst, key="key", val="text", indent=0): def shortcuts(k): if k == " ": k = "page down" + elif k == "ctrl f": + k = "page down" + elif k == "ctrl b": + k = "page up" elif k == "j": k = "down" elif k == "k": diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index ba87348d..74748030 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -31,6 +31,7 @@ class HelpView(urwid.ListBox): ("g, G", "go to beginning, end"), ("space", "page down"), ("pg up/down", "page up/down"), + ("ctrl+b/ctrl+f", "page up/down"), ("arrows", "up, down, left, right"), ] text.extend( diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index 8e56c699..8740927e 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -1,12 +1,11 @@ from __future__ import (absolute_import, print_function, division) -import itertools import sys import traceback import six from netlib import tcp -from netlib.exceptions import HttpException, HttpReadDisconnect, TcpException +from netlib.exceptions import HttpException, HttpReadDisconnect, NetlibException from netlib.http import http1, Headers from netlib.http import CONTENT_MISSING from netlib.tcp import Address @@ -319,7 +318,7 @@ class HttpLayer(Layer): except HttpReadDisconnect: # don't throw an error for disconnects that happen before/between requests. return - except (HttpException, TcpException) as e: + except NetlibException as e: self.send_error_response(400, repr(e)) six.reraise(ProtocolException, ProtocolException("Error in HTTP connection: %s" % repr(e)), sys.exc_info()[2]) @@ -366,7 +365,7 @@ class HttpLayer(Layer): self.handle_upstream_mode_connect(flow.request.copy()) return - except (HttpException, TcpException) as e: + except NetlibException as e: self.send_error_response(502, repr(e)) if not flow.response: @@ -392,7 +391,7 @@ class HttpLayer(Layer): try: response = make_error_response(code, message) self.send_response(response) - except TcpException: + except NetlibException: pass def change_upstream_proxy_server(self, address): @@ -440,7 +439,7 @@ class HttpLayer(Layer): try: get_response() - except (TcpException, HttpException) as v: + except NetlibException as v: self.log( "server communication error: %s" % repr(v), level="debug" diff --git a/test/test_server.py b/test/test_server.py index 9488595f..0bf8b9c7 100644 --- a/test/test_server.py +++ b/test/test_server.py @@ -516,7 +516,9 @@ class TestProxy(tservers.HTTPProxTest): assert f.status_code == 304 response = self.master.state.view[0].response - assert 0.9 <= response.timestamp_end - response.timestamp_start <= 1.2 + # time.sleep might be a little bit shorter than a second, + # we observed up to 0.93s on appveyor. + assert 0.8 <= response.timestamp_end - response.timestamp_start def test_request_timestamps(self): # test that we notice a delay between timestamps in request object @@ -537,21 +539,7 @@ class TestProxy(tservers.HTTPProxTest): assert response.status_code == 304 # sanity test for our low level request # time.sleep might be a little bit shorter than a second, # we observed up to 0.93s on appveyor. - assert 0.8 < (request.timestamp_end - request.timestamp_start) < 1.2 - - def test_request_timestamps_not_affected_by_client_time(self): - # test that don't include user wait time in request's timestamps - - f = self.pathod("304:b@10k") - assert f.status_code == 304 - f = self.pathod("304:b@10k") - assert f.status_code == 304 - - request = self.master.state.view[0].request - assert request.timestamp_end - request.timestamp_start <= 0.1 - - request = self.master.state.view[1].request - assert request.timestamp_end - request.timestamp_start <= 0.1 + assert 0.8 < (request.timestamp_end - request.timestamp_start) def test_request_tcp_setup_timestamp_presence(self): # tests that the client_conn a tcp connection has a tcp_setup_timestamp |