MCPcopy Index your code
hub / github.com/python-websockets/websockets / AlterRequest

Class AlterRequest

tests/proxy.py:47–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45
46
47class AlterRequest:
48 def load(self, loader):
49 loader.add_option(
50 name="break_http_connect",
51 typespec=bool,
52 default=False,
53 help="Respond to HTTP CONNECT requests with a 999 status code.",
54 )
55 loader.add_option(
56 name="close_http_connect",
57 typespec=bool,
58 default=False,
59 help="Do not respond to HTTP CONNECT requests.",
60 )
61
62 def http_connect(self, flow):
63 if ctx.options.break_http_connect:
64 # mitmproxy can send a response with a status code not between 100
65 # and 599, while websockets treats it as a protocol error.
66 # This is used for testing HTTP parsing errors.
67 flow.response = Response.make(999, "not a valid HTTP response")
68 if ctx.options.close_http_connect:
69 flow.kill()
70
71
72class ProxyMixin:

Callers 1

run_proxyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…