How to use the httptools.parser.errors.HttpParserInvalidMethodError function in httptools

To help you get started, we’ve selected a few httptools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trollfot / trinket / src / trinket / request.py View on Github external
def data_received(self, data: bytes):
        try:
            self.parser.feed_data(data)
        except HttpParserUpgrade:
            self.request.upgrade = True
        except (HttpParserError, HttpParserInvalidMethodError) as exc:
            # We should log the exc.
            raise HTTPError(
                HTTPStatus.BAD_REQUEST, 'Unparsable request.')
github RevengeComing / DemonHunter / demonhunter / nodes / honeypots / http / server.py View on Github external
def data_received(self, data):
        hrp = HttpRequestParser(self)
        try:
            hrp.feed_data(data)
            self.request_version = hrp.get_http_version()
            self.send_response()
        except HttpParserInvalidMethodError:
            self.data = data
            self.error = True
            self.bad_request()
        except HttpParserError:
            self.data = data
            self.error = True
            self.bad_request()