diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-08-30 03:42:11 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-08-30 03:42:11 +0200 |
commit | 3873e08339fd701738a1522af32e37363fcec14b (patch) | |
tree | 80b17775ca5f13b926d37e74356c3c12cec6a711 /examples/ignore_websocket.py | |
parent | 08655cb9567f502ec79799499968c57125d9a205 (diff) | |
download | mitmproxy-3873e08339fd701738a1522af32e37363fcec14b.tar.gz mitmproxy-3873e08339fd701738a1522af32e37363fcec14b.tar.bz2 mitmproxy-3873e08339fd701738a1522af32e37363fcec14b.zip |
remove old code
Diffstat (limited to 'examples/ignore_websocket.py')
-rw-r--r-- | examples/ignore_websocket.py | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/examples/ignore_websocket.py b/examples/ignore_websocket.py deleted file mode 100644 index 57e11d5b..00000000 --- a/examples/ignore_websocket.py +++ /dev/null @@ -1,37 +0,0 @@ -# This script makes mitmproxy switch to passthrough mode for all HTTP -# responses with "Connection: Upgrade" header. This is useful to make -# WebSockets work in untrusted environments. -# -# Note: Chrome (and possibly other browsers), when explicitly configured -# to use a proxy (i.e. mitmproxy's regular mode), send a CONNECT request -# to the proxy before they initiate the websocket connection. -# To make WebSockets work in these cases, supply -# `--ignore :80$` as an additional parameter. -# (see http://mitmproxy.org/doc/features/passthrough.html) - -import netlib.http.semantics - -from libmproxy.protocol.tcp import TCPHandler -from libmproxy.protocol import KILL -from libmproxy.script import concurrent - - -def start(context, argv): - netlib.http.semantics.Request._headers_to_strip_off.remove("Connection") - netlib.http.semantics.Request._headers_to_strip_off.remove("Upgrade") - - -def done(context): - netlib.http.semantics.Request._headers_to_strip_off.append("Connection") - netlib.http.semantics.Request._headers_to_strip_off.append("Upgrade") - - -@concurrent -def response(context, flow): - value = flow.response.headers.get_first("Connection", None) - if value and value.upper() == "UPGRADE": - # We need to send the response manually now... - flow.client_conn.send(flow.client_conn.protocol.assemble(flow.response)) - # ...and then delegate to tcp passthrough. - TCPHandler(flow.live.c, log=False).handle_messages() - flow.reply(KILL) |