mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
fix docs and url encoding
This commit is contained in:
parent
417c213dd7
commit
cee4da4e8c
@ -49,13 +49,15 @@ The `map_remote` option lets you specify an arbitrary number of patterns that
|
|||||||
define replacements within HTTP request URLs before they are sent to a server.
|
define replacements within HTTP request URLs before they are sent to a server.
|
||||||
The substituted URL is fetched instead of the original resource
|
The substituted URL is fetched instead of the original resource
|
||||||
and the corresponding HTTP response is returned transparently to the client.
|
and the corresponding HTTP response is returned transparently to the client.
|
||||||
|
Note that if the original destination uses HTTP2, the substituted destination
|
||||||
|
needs to support HTTP2 as well, otherwise the substituted request may fail.
|
||||||
`map_remote` patterns looks like this:
|
`map_remote` patterns looks like this:
|
||||||
|
|
||||||
```
|
```
|
||||||
:flow-filter:regex:replacement
|
|flow-filter|regex|replacement
|
||||||
:flow-filter:regex:@file-path
|
|flow-filter|regex|@file-path
|
||||||
:regex:replacement
|
|regex|replacement
|
||||||
:regex:@file-path
|
|regex|@file-path
|
||||||
```
|
```
|
||||||
|
|
||||||
* **flow-filter** is an optional mitmproxy [filter expression]({{< relref "concepts-filters">}})
|
* **flow-filter** is an optional mitmproxy [filter expression]({{< relref "concepts-filters">}})
|
||||||
@ -70,10 +72,12 @@ The _separator_ is arbitrary, and is defined by the first character.
|
|||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
Map all requests ending with `.jpg` to `https://placedog.net/640/480?random`:
|
Map all requests ending with `.jpg` to `https://placedog.net/640/480?random`.
|
||||||
|
Note that this might fail if the original HTTP request destination uses HTTP2 but the replaced
|
||||||
|
destination does not support HTTP2.
|
||||||
|
|
||||||
```
|
```
|
||||||
:.*\.jpg$:https://placedog.net/640/480?random
|
|.*\.jpg$|https://placedog.net/640/480?random
|
||||||
```
|
```
|
||||||
|
|
||||||
Re-route all GET requests from `example.org` to `mitmproxy.org` (using `|` as the separator):
|
Re-route all GET requests from `example.org` to `mitmproxy.org` (using `|` as the separator):
|
||||||
|
@ -4,7 +4,6 @@ import typing
|
|||||||
|
|
||||||
from mitmproxy import exceptions
|
from mitmproxy import exceptions
|
||||||
from mitmproxy import ctx
|
from mitmproxy import ctx
|
||||||
from mitmproxy.utils import strutils
|
|
||||||
from mitmproxy.addons.modifyheaders import parse_modify_spec, ModifySpec
|
from mitmproxy.addons.modifyheaders import parse_modify_spec, ModifySpec
|
||||||
|
|
||||||
|
|
||||||
@ -62,5 +61,5 @@ class MapRemote:
|
|||||||
return
|
return
|
||||||
|
|
||||||
replacements = 0
|
replacements = 0
|
||||||
obj.url, replacements = re.subn(search, repl, strutils.escaped_str_to_bytes(obj.pretty_url), flags=re.DOTALL)
|
obj.url, replacements = re.subn(search, repl, obj.pretty_url.encode("utf8", "surrogateescape"), flags=re.DOTALL)
|
||||||
return replacements
|
return replacements
|
||||||
|
Loading…
Reference in New Issue
Block a user