MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_server_aborts

Function test_server_aborts

test/mitmproxy/proxy/layers/http/test_http.py:781–808  ·  view source on GitHub ↗

Test the scenario where the server doesn't serve a response

(tctx, data)

Source from the content-addressed store, hash-verified

779 ],
780)
781def test_server_aborts(tctx, data):
782 """Test the scenario where the server doesn't serve a response"""
783 server = Placeholder(Server)
784 flow = Placeholder(HTTPFlow)
785 playbook = Playbook(http.HttpLayer(tctx, HTTPMode.regular), hooks=False)
786 assert (
787 playbook
788 >> DataReceived(
789 tctx.client,
790 b"GET http://example.com/ HTTP/1.1\r\nHost: example.com\r\n\r\n",
791 )
792 << OpenConnection(server)
793 >> reply(None)
794 << SendData(server, b"GET / HTTP/1.1\r\nHost: example.com\r\n\r\n")
795 )
796 if data:
797 playbook >> DataReceived(server, data)
798 assert (
799 playbook
800 >> ConnectionClosed(server)
801 << CloseConnection(server)
802 << http.HttpErrorHook(flow)
803 >> reply()
804 << SendData(tctx.client, BytesMatching(b"502 Bad Gateway"))
805 << CloseConnection(tctx.client)
806 )
807 assert flow().error
808 assert not flow().live
809
810
811@pytest.mark.parametrize("redirect", ["", "change-destination", "change-proxy"])

Callers

nothing calls this directly

Calls 9

PlaceholderFunction · 0.90
PlaybookClass · 0.90
DataReceivedClass · 0.90
OpenConnectionClass · 0.90
replyClass · 0.90
SendDataClass · 0.90
ConnectionClosedClass · 0.90
CloseConnectionClass · 0.90
BytesMatchingFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…