Request对象属性
假如你的URL为:https://xxx.com/xxx/xxx
Request对象属性 作用 例子 flow.request
获取mitmproxy.http.HTTPRequest对象 返回对象 flow.request.port
获取request端口号 返回端口号 flow.request.url
获取request的url 返回https://xxx.com flow.request.pretty_url
获取request的pretty_url
和普通url很类似
但这个主要用于
mitmproxy的透明模式直接返回url flow.request.host
获取request的host 返回
xxx.comflow.request.pretty_host
获取当前request的pretty_host
和host_header很类似
但这个主要用于
mitmproxy的透明模式返回
xxx.comflow.request.host_header
获取当前request的
host_header此属性是根据
headers的host进行映射的返回
xxx.comflow.request.method
获取request的method 返回
GET、POST等等flow.request.scheme
获取request的scheme 返回
http、https等等协议flow.request.path
获取request的path 返回
URL的/xxx/xxxflow.request.multipart_form
获取request的多部分表单数据 返回
MultiDictView对象flow.request.path_components
获取request的url的路径(元组形式) 返回元组 flow.request.urlencoded_form
获取当前request的url编码表单数据 返回
MultiDictView对象flow.request.first_line_format
根据HTTP的规范
origin-form和asterisk-form
将被判断为relative(相对的)返回str
Request对象方法
假如你的URL为:https://xxx.com
Request对象方法 作用例子 flow.request.text.replace(self, pattern, repl, flags=0, count=0)
替换request的内容
pattern:被替换的内容(正则表达式模式)
repl:替换的内容
flags:标记数量
count:替换次数常用于 text.replace('xxx','xxx')
与get_text()或text属性配合使用即可flow.request.make(method: str, url: str, content: Union[bytes, str] = '', headers: Union[mitmproxy.net.http.headers.Headers, Dict[Union[str, bytes], Union[str, bytes]], Iterable[Tuple[bytes, bytes]]] = ()) -> 'Request'
生成新的request的
method、url、content、headers等等
用于修改或替换request
主要用途:捉弄别人返回Request对象
直接使用flow.request.make(method='GET',url='https://xxx.com',headers={'xxx':'xxx'})
flow.request.anticache(self)
删除request可能产生的缓存
删除了协议头的ETags和If-Modified-Since直接 anticache()
即可flow.request.anticomp(self)
删除request可能压缩数据资源的标头 直接 anticomp()
即可flow.request.constrain_encoding(self)
限制request的Accept-Encoding值
方便我们之后解码直接 constrain_encoding()
即可