mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 04:19:40 +00:00
This commit is contained in:
parent
0454f63e98
commit
02d2b6d310
@ -6,6 +6,8 @@
|
||||
([#5227](https://github.com/mitmproxy/mitmproxy/issues/5227), @mhils)
|
||||
* Console Performance Improvements
|
||||
([#3427](https://github.com/mitmproxy/mitmproxy/issues/3427), @BkPHcgQL3V)
|
||||
* Warn users if server side event responses are received without streaming.
|
||||
([#4469](https://github.com/mitmproxy/mitmproxy/issues/4469), @mhils)
|
||||
* Add flatpak support to the browser addon
|
||||
([#5200](https://github.com/mitmproxy/mitmproxy/issues/5200), @pauloromeira)
|
||||
* Add example addon to dump contents to files based on a filter expression
|
||||
|
@ -358,7 +358,8 @@ By default, mitmproxy will read an entire request/response, perform any
|
||||
indicated manipulations on it, and then send the message on to the other party.
|
||||
This can be problematic when downloading or uploading large files. When
|
||||
streaming is enabled, message bodies are not buffered on the proxy but instead
|
||||
sent directly to the server/client. HTTP headers are still fully buffered before
|
||||
sent directly to the server/client. This currently means that the message body
|
||||
will not be accessible within mitmproxy. HTTP headers are still fully buffered before
|
||||
being sent.
|
||||
|
||||
Request/response streaming is enabled by specifying a size cutoff in the
|
||||
|
19
mitmproxy/addons/server_side_events.py
Normal file
19
mitmproxy/addons/server_side_events.py
Normal file
@ -0,0 +1,19 @@
|
||||
from mitmproxy import ctx, http
|
||||
|
||||
|
||||
class ServerSideEvents:
|
||||
"""
|
||||
Server-Side Events are currently swallowed if there's no streaming,
|
||||
see https://github.com/mitmproxy/mitmproxy/issues/4469.
|
||||
|
||||
Until this bug is fixed, this addon warns the user about this.
|
||||
"""
|
||||
|
||||
def response(self, flow: http.HTTPFlow):
|
||||
assert flow.response
|
||||
is_sse = flow.response.headers.get("content-type", "").startswith("text/event-stream")
|
||||
if is_sse and not flow.response.stream:
|
||||
ctx.log.warn(
|
||||
"mitmproxy currently does not support server side events. As a workaround, you can enable response "
|
||||
"streaming for such flows: https://github.com/mitmproxy/mitmproxy/issues/4469"
|
||||
)
|
12
test/mitmproxy/addons/test_server_side_events.py
Normal file
12
test/mitmproxy/addons/test_server_side_events.py
Normal file
@ -0,0 +1,12 @@
|
||||
from mitmproxy.addons.server_side_events import ServerSideEvents
|
||||
from mitmproxy.test import taddons
|
||||
from mitmproxy.test.tflow import tflow
|
||||
|
||||
|
||||
async def test_simple():
|
||||
s = ServerSideEvents()
|
||||
with taddons.context() as tctx:
|
||||
f = tflow(resp=True)
|
||||
f.response.headers["content-type"] = "text/event-stream"
|
||||
s.response(f)
|
||||
await tctx.master.await_log("mitmproxy currently does not support server side events.")
|
@ -39,6 +39,7 @@ def test_format_keyvals():
|
||||
|
||||
|
||||
def test_truncated_text():
|
||||
urwid.set_encoding("utf8")
|
||||
half_width_text = common.TruncatedText("Half-width", [])
|
||||
full_width_text = common.TruncatedText("FULL-WIDTH", [])
|
||||
assert half_width_text.render((10,))
|
||||
|
Loading…
Reference in New Issue
Block a user