diff options
-rw-r--r-- | docs/src/content/tools-mitmdump.md | 4 | ||||
-rw-r--r-- | docs/src/content/tute-clientreplay.md | 2 | ||||
-rw-r--r-- | mitmproxy/net/http/headers.py | 8 | ||||
-rw-r--r-- | test/mitmproxy/net/http/test_headers.py | 2 |
4 files changed, 12 insertions, 4 deletions
diff --git a/docs/src/content/tools-mitmdump.md b/docs/src/content/tools-mitmdump.md index fb6a6c0c..dcc3bbf6 100644 --- a/docs/src/content/tools-mitmdump.md +++ b/docs/src/content/tools-mitmdump.md @@ -53,7 +53,7 @@ See the [client-side replay]({{< relref "overview-features#client-side-replay" ### Running a script {{< highlight bash >}} -mitmdump -s examples/add_header.py +mitmdump -s examples/simple/add_header.py {{< / highlight >}} This runs the **add_header.py** example script, which simply adds a new @@ -62,7 +62,7 @@ header to all responses. ### Scripted data transformation {{< highlight bash >}} -mitmdump -ns examples/add_header.py -r srcfile -w dstfile +mitmdump -ns examples/simple/add_header.py -r srcfile -w dstfile {{< / highlight >}} This command loads flows from **srcfile**, transforms it according to diff --git a/docs/src/content/tute-clientreplay.md b/docs/src/content/tute-clientreplay.md index 275edfe6..048fd0a5 100644 --- a/docs/src/content/tute-clientreplay.md +++ b/docs/src/content/tute-clientreplay.md @@ -42,7 +42,7 @@ And that's it\! You now have a serialised version of the login process in the file wireless-login, and you can replay it at any time like this: {{< highlight bash >}} -mitmdump -c wireless-login +mitmdump -C wireless-login {{< / highlight >}} ## Embellishments diff --git a/mitmproxy/net/http/headers.py b/mitmproxy/net/http/headers.py index 8a58cbbc..baed7e06 100644 --- a/mitmproxy/net/http/headers.py +++ b/mitmproxy/net/http/headers.py @@ -162,8 +162,12 @@ class Headers(multidict.MultiDict): pattern = re.compile(pattern, flags) replacements = 0 flag_count = count > 0 + count_reached = False fields = [] for name, value in self.fields: + if count_reached: + fields.append((name, value)) + continue line, n = pattern.subn(repl, name + b": " + value, count=count) try: name, value = line.split(b": ", 1) @@ -173,10 +177,12 @@ class Headers(multidict.MultiDict): pass else: replacements += n + fields.append((name, value)) if flag_count: count -= n if count == 0: - break + count_reached = True + continue fields.append((name, value)) self.fields = tuple(fields) return replacements diff --git a/test/mitmproxy/net/http/test_headers.py b/test/mitmproxy/net/http/test_headers.py index 8fc8b027..5f208dcb 100644 --- a/test/mitmproxy/net/http/test_headers.py +++ b/test/mitmproxy/net/http/test_headers.py @@ -88,6 +88,8 @@ class TestHeaders: headers = Headers(Host="foobarfoo.com", Accept="foo/bar") replacements = headers.replace("foo", "bar", count=1) assert replacements == 1 + assert headers["Host"] == "barbarfoo.com" + assert headers["Accept"] == "foo/bar" def test_parse_content_type(): |