aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/flowbasic5
-rw-r--r--examples/flowwriter.py5
-rw-r--r--examples/read_dumpfile2
-rw-r--r--examples/redirect_requests.py4
4 files changed, 7 insertions, 9 deletions
diff --git a/examples/flowbasic b/examples/flowbasic
index bac98916..cb1e4ea4 100755
--- a/examples/flowbasic
+++ b/examples/flowbasic
@@ -8,7 +8,7 @@
Note that request and response messages are not automatically replied to,
so we need to implement handlers to do this.
"""
-from mitmproxy import flow, controller, options
+from mitmproxy import controller, options, master
from mitmproxy.proxy import ProxyServer, ProxyConfig
@@ -37,7 +37,6 @@ class MyMaster(master.Master):
opts = options.Options(cadir="~/.mitmproxy/")
config = ProxyConfig(opts)
-state = state.State()
server = ProxyServer(config)
-m = MyMaster(opts, server, state)
+m = MyMaster(opts, server)
m.run()
diff --git a/examples/flowwriter.py b/examples/flowwriter.py
index df2e5a40..a9768542 100644
--- a/examples/flowwriter.py
+++ b/examples/flowwriter.py
@@ -1,7 +1,6 @@
import random
import sys
-
-from mitmproxy.flow import FlowWriter
+from mitmproxy import io
class Writer:
@@ -10,7 +9,7 @@ class Writer:
f = sys.stdout
else:
f = open(path, "wb")
- self.w = FlowWriter(f)
+ self.w = io.FlowWriter(f)
def response(self, flow):
if random.choice([True, False]):
diff --git a/examples/read_dumpfile b/examples/read_dumpfile
index b1001c3d..e0e9064a 100644
--- a/examples/read_dumpfile
+++ b/examples/read_dumpfile
@@ -9,7 +9,7 @@ import pprint
import sys
with open(sys.argv[1], "rb") as logfile:
- freader = flow.FlowReader(logfile)
+ freader = io.FlowReader(logfile)
pp = pprint.PrettyPrinter(indent=4)
try:
for f in freader.stream():
diff --git a/examples/redirect_requests.py b/examples/redirect_requests.py
index bbb84e2f..c28042db 100644
--- a/examples/redirect_requests.py
+++ b/examples/redirect_requests.py
@@ -1,7 +1,7 @@
"""
This example shows two ways to redirect flows to other destinations.
"""
-from mitmproxy.models import HTTPResponse
+from mitmproxy import http
def request(flow):
@@ -11,7 +11,7 @@ def request(flow):
# Method 1: Answer with a locally generated response
if flow.request.pretty_host.endswith("example.com"):
- flow.response = HTTPResponse.make(200, b"Hello World", {"Content-Type": "text/html"})
+ flow.response = http.HTTPResponse.make(200, b"Hello World", {"Content-Type": "text/html"})
# Method 2: Redirect the request to a different server
if flow.request.pretty_host.endswith("example.org"):