flow.request/flow.response.decode(self, strict=True) |
根据当前request的 Content-Encoding标头进行解码 当Content-Encoding标头不存在 并且strict=True时 即触发ValueError异常 |
直接decode()即可 |
flow.request/flow.response.encode(self, e) |
对当前request进行编码 编码格式有: “gzip”, “deflate”, “identity”, “br” |
直接使用encode('gzip') |
flow.request/flow.response.get_state(self) |
获取request的状态 |
直接使用get_state() |
flow.request/flow.response.set_state(self, state) |
设置request的状态 |
直接使用set_state(state) 要和get_state() 配合使用 |
flow.request/flow.response.get_content(self, strict: bool = True) -> bytes |
使用内容编码标头 (例如gzip)解码的 request消息正文 |
直接使用
get_content() 返回二进制数据 |
flow.request/flow.response.set_content(self, value: Union[bytes, NoneType]) -> None |
设置request的 二进制数据 |
直接使用set_content(b'xxx') 可用get_content()查看新内容 |
flow.request/flow.response.get_text(self, strict: bool = True) -> Union[str, NoneType] |
使用内容编码标头 (例如gzip)和Content-Encoding标头字符集 解码的HTTP消息正文 |
此方法可以自动解码 源码有多种方案解码 直接使用get_text() 返回str |
flow.request/flow.response.set_text(self, text: Union[str, NoneType]) -> None |
设置request的text |
直接使用set_text('xxx') 可用get_text() 查看新内容 |