How to use the httptools.parser.errors.HttpParserError 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 vltr / sanic-boom / src / sanic_boom / protocol.py View on Github external
if self._total_request_size > self.request_max_size:
            self.write_error(PayloadTooLarge("Payload too large"))

        # Create parser if this is the first time we're receiving data
        if self.parser is None:
            assert self.request is None
            self.headers = []
            self.parser = HttpRequestParser(self)

        # requests count
        self.state["requests_count"] = self.state["requests_count"] + 1

        # Parse request chunk or close connection
        try:
            self.parser.feed_data(data)
        except HttpParserError:
            message = "Bad Request"
            if self._debug:
                message += "\n" + traceback.format_exc()
            self.write_error(InvalidUsage(message))
github MagicStack / httptools / httptools / parser / errors.py View on Github external
'HttpParserUpgrade')


class HttpParserError(Exception):
    pass


class HttpParserCallbackError(HttpParserError):
    pass


class HttpParserInvalidStatusError(HttpParserError):
    pass


class HttpParserInvalidMethodError(HttpParserError):
    pass


class HttpParserInvalidURLError(HttpParserError):
    pass


class HttpParserUpgrade(Exception):
    pass
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()
github MagicStack / httptools / httptools / parser / errors.py View on Github external
pass


class HttpParserCallbackError(HttpParserError):
    pass


class HttpParserInvalidStatusError(HttpParserError):
    pass


class HttpParserInvalidMethodError(HttpParserError):
    pass


class HttpParserInvalidURLError(HttpParserError):
    pass


class HttpParserUpgrade(Exception):
    pass
github MagicStack / httptools / httptools / parser / errors.py View on Github external
'HttpParserCallbackError',
           'HttpParserInvalidStatusError',
           'HttpParserInvalidMethodError',
           'HttpParserInvalidURLError',
           'HttpParserUpgrade')


class HttpParserError(Exception):
    pass


class HttpParserCallbackError(HttpParserError):
    pass


class HttpParserInvalidStatusError(HttpParserError):
    pass


class HttpParserInvalidMethodError(HttpParserError):
    pass


class HttpParserInvalidURLError(HttpParserError):
    pass


class HttpParserUpgrade(Exception):
    pass
github MagicStack / httptools / httptools / parser / errors.py View on Github external
__all__ = ('HttpParserError',
           'HttpParserCallbackError',
           'HttpParserInvalidStatusError',
           'HttpParserInvalidMethodError',
           'HttpParserInvalidURLError',
           'HttpParserUpgrade')


class HttpParserError(Exception):
    pass


class HttpParserCallbackError(HttpParserError):
    pass


class HttpParserInvalidStatusError(HttpParserError):
    pass


class HttpParserInvalidMethodError(HttpParserError):
    pass


class HttpParserInvalidURLError(HttpParserError):
    pass


class HttpParserUpgrade(Exception):
github huge-success / sanic / sanic / server.py View on Github external
if self._total_request_size > self.request_max_size:
            self.write_error(PayloadTooLarge("Payload Too Large"))

        # Create parser if this is the first time we're receiving data
        if self.parser is None:
            assert self.request is None
            self.headers = []
            self.parser = HttpRequestParser(self)

        # requests count
        self.state["requests_count"] = self.state["requests_count"] + 1

        # Parse request chunk or close connection
        try:
            self.parser.feed_data(data)
        except HttpParserError:
            message = "Bad Request"
            if self._debug:
                message += "\n" + traceback.format_exc()
            self.write_error(InvalidUsage(message))