Voice et bot modif
This commit is contained in:
parent
189d56026b
commit
7333a22bcd
10774 changed files with 634644 additions and 933308 deletions
|
|
@ -1,7 +1,6 @@
|
|||
"""Low-level http related exceptions."""
|
||||
|
||||
from textwrap import indent
|
||||
from typing import Optional, Union
|
||||
|
||||
from .typedefs import _CIMultiDict
|
||||
|
||||
|
|
@ -25,9 +24,9 @@ class HttpProcessingError(Exception):
|
|||
def __init__(
|
||||
self,
|
||||
*,
|
||||
code: Optional[int] = None,
|
||||
code: int | None = None,
|
||||
message: str = "",
|
||||
headers: Optional[_CIMultiDict] = None,
|
||||
headers: _CIMultiDict | None = None,
|
||||
) -> None:
|
||||
if code is not None:
|
||||
self.code = code
|
||||
|
|
@ -47,7 +46,7 @@ class BadHttpMessage(HttpProcessingError):
|
|||
code = 400
|
||||
message = "Bad Request"
|
||||
|
||||
def __init__(self, message: str, *, headers: Optional[_CIMultiDict] = None) -> None:
|
||||
def __init__(self, message: str, *, headers: _CIMultiDict | None = None) -> None:
|
||||
super().__init__(message=message, headers=headers)
|
||||
self.args = (message,)
|
||||
|
||||
|
|
@ -75,21 +74,22 @@ class ContentLengthError(PayloadEncodingError):
|
|||
|
||||
|
||||
class DecompressSizeError(PayloadEncodingError):
|
||||
"""Decompressed size exceeds the configured limit."""
|
||||
"""Deprecated. Removed in v4."""
|
||||
|
||||
|
||||
class LineTooLong(BadHttpMessage):
|
||||
def __init__(
|
||||
self, line: str, limit: str = "Unknown", actual_size: str = "Unknown"
|
||||
self,
|
||||
line: str | bytes,
|
||||
limit: str | int = "Unknown",
|
||||
actual_size: str = "Unknown",
|
||||
) -> None:
|
||||
super().__init__(
|
||||
f"Got more than {limit} bytes ({actual_size}) when reading {line}."
|
||||
)
|
||||
super().__init__(f"Got more than {limit} bytes when reading: {line!r}.")
|
||||
self.args = (line, limit, actual_size)
|
||||
|
||||
|
||||
class InvalidHeader(BadHttpMessage):
|
||||
def __init__(self, hdr: Union[bytes, str]) -> None:
|
||||
def __init__(self, hdr: bytes | str) -> None:
|
||||
hdr_s = hdr.decode(errors="backslashreplace") if isinstance(hdr, bytes) else hdr
|
||||
super().__init__(f"Invalid HTTP header: {hdr!r}")
|
||||
self.hdr = hdr_s
|
||||
|
|
@ -97,7 +97,7 @@ class InvalidHeader(BadHttpMessage):
|
|||
|
||||
|
||||
class BadStatusLine(BadHttpMessage):
|
||||
def __init__(self, line: str = "", error: Optional[str] = None) -> None:
|
||||
def __init__(self, line: str = "", error: str | None = None) -> None:
|
||||
if not isinstance(line, str):
|
||||
line = repr(line)
|
||||
super().__init__(error or f"Bad status line {line!r}")
|
||||
|
|
@ -108,7 +108,9 @@ class BadStatusLine(BadHttpMessage):
|
|||
class BadHttpMethod(BadStatusLine):
|
||||
"""Invalid HTTP method in status line."""
|
||||
|
||||
def __init__(self, line: str = "", error: Optional[str] = None) -> None:
|
||||
def __init__(self, line: str = "", error: str | None = None) -> None:
|
||||
if error is None and line.startswith("\x16\x03"):
|
||||
error = "Received HTTPS traffic on an HTTP port"
|
||||
super().__init__(line, error or f"Bad HTTP method in status line {line!r}")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue