| 45 | |
| 46 | |
| 47 | class 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 | |
| 72 | class ProxyMixin: |
no outgoing calls
no test coverage detected
searching dependent graphs…