massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / http / client.pyi
1 import email.message
2 import io
3 import ssl
4 import sys
5 import types
6 from _typeshed import Self, WriteableBuffer
7 from socket import socket
8 from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, Mapping, Protocol, Type, TypeVar, Union, overload
9
10 _DataType = Union[bytes, IO[Any], Iterable[bytes], str]
11 _T = TypeVar("_T")
12
13 HTTP_PORT: int
14 HTTPS_PORT: int
15
16 CONTINUE: int
17 SWITCHING_PROTOCOLS: int
18 PROCESSING: int
19
20 OK: int
21 CREATED: int
22 ACCEPTED: int
23 NON_AUTHORITATIVE_INFORMATION: int
24 NO_CONTENT: int
25 RESET_CONTENT: int
26 PARTIAL_CONTENT: int
27 MULTI_STATUS: int
28 IM_USED: int
29
30 MULTIPLE_CHOICES: int
31 MOVED_PERMANENTLY: int
32 FOUND: int
33 SEE_OTHER: int
34 NOT_MODIFIED: int
35 USE_PROXY: int
36 TEMPORARY_REDIRECT: int
37
38 BAD_REQUEST: int
39 UNAUTHORIZED: int
40 PAYMENT_REQUIRED: int
41 FORBIDDEN: int
42 NOT_FOUND: int
43 METHOD_NOT_ALLOWED: int
44 NOT_ACCEPTABLE: int
45 PROXY_AUTHENTICATION_REQUIRED: int
46 REQUEST_TIMEOUT: int
47 CONFLICT: int
48 GONE: int
49 LENGTH_REQUIRED: int
50 PRECONDITION_FAILED: int
51 REQUEST_ENTITY_TOO_LARGE: int
52 REQUEST_URI_TOO_LONG: int
53 UNSUPPORTED_MEDIA_TYPE: int
54 REQUESTED_RANGE_NOT_SATISFIABLE: int
55 EXPECTATION_FAILED: int
56 UNPROCESSABLE_ENTITY: int
57 LOCKED: int
58 FAILED_DEPENDENCY: int
59 UPGRADE_REQUIRED: int
60 PRECONDITION_REQUIRED: int
61 TOO_MANY_REQUESTS: int
62 REQUEST_HEADER_FIELDS_TOO_LARGE: int
63
64 INTERNAL_SERVER_ERROR: int
65 NOT_IMPLEMENTED: int
66 BAD_GATEWAY: int
67 SERVICE_UNAVAILABLE: int
68 GATEWAY_TIMEOUT: int
69 HTTP_VERSION_NOT_SUPPORTED: int
70 INSUFFICIENT_STORAGE: int
71 NOT_EXTENDED: int
72 NETWORK_AUTHENTICATION_REQUIRED: int
73
74 responses: dict[int, str]
75
76 class HTTPMessage(email.message.Message):
77     def getallmatchingheaders(self, name: str) -> list[str]: ...  # undocumented
78
79 def parse_headers(fp: io.BufferedIOBase, _class: Callable[[], email.message.Message] = ...) -> HTTPMessage: ...
80
81 class HTTPResponse(io.BufferedIOBase, BinaryIO):
82     msg: HTTPMessage
83     headers: HTTPMessage
84     version: int
85     debuglevel: int
86     fp: io.BufferedReader
87     closed: bool
88     status: int
89     reason: str
90     chunked: bool
91     chunk_left: int | None
92     length: int | None
93     will_close: bool
94     def __init__(self, sock: socket, debuglevel: int = ..., method: str | None = ..., url: str | None = ...) -> None: ...
95     def peek(self, n: int = ...) -> bytes: ...
96     def read(self, amt: int | None = ...) -> bytes: ...
97     def read1(self, n: int = ...) -> bytes: ...
98     def readinto(self, b: WriteableBuffer) -> int: ...
99     def readline(self, limit: int = ...) -> bytes: ...  # type: ignore
100     @overload
101     def getheader(self, name: str) -> str | None: ...
102     @overload
103     def getheader(self, name: str, default: _T) -> str | _T: ...
104     def getheaders(self) -> list[tuple[str, str]]: ...
105     def fileno(self) -> int: ...
106     def isclosed(self) -> bool: ...
107     def __iter__(self) -> Iterator[bytes]: ...
108     def __enter__(self: Self) -> Self: ...
109     def __exit__(
110         self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
111     ) -> bool | None: ...
112     def info(self) -> email.message.Message: ...
113     def geturl(self) -> str: ...
114     def getcode(self) -> int: ...
115     def begin(self) -> None: ...
116
117 # This is an API stub only for the class below, not a class itself.
118 # urllib.request uses it for a parameter.
119 class _HTTPConnectionProtocol(Protocol):
120     if sys.version_info >= (3, 7):
121         def __call__(
122             self,
123             host: str,
124             port: int | None = ...,
125             timeout: float = ...,
126             source_address: tuple[str, int] | None = ...,
127             blocksize: int = ...,
128         ) -> HTTPConnection: ...
129     else:
130         def __call__(
131             self, host: str, port: int | None = ..., timeout: float = ..., source_address: tuple[str, int] | None = ...
132         ) -> HTTPConnection: ...
133
134 class HTTPConnection:
135     auto_open: int  # undocumented
136     debuglevel: int
137     default_port: int  # undocumented
138     response_class: Type[HTTPResponse]  # undocumented
139     timeout: float | None
140     host: str
141     port: int
142     sock: Any
143     if sys.version_info >= (3, 7):
144         def __init__(
145             self,
146             host: str,
147             port: int | None = ...,
148             timeout: float | None = ...,
149             source_address: tuple[str, int] | None = ...,
150             blocksize: int = ...,
151         ) -> None: ...
152     else:
153         def __init__(
154             self, host: str, port: int | None = ..., timeout: float | None = ..., source_address: tuple[str, int] | None = ...
155         ) -> None: ...
156     def request(
157         self, method: str, url: str, body: _DataType | None = ..., headers: Mapping[str, str] = ..., *, encode_chunked: bool = ...
158     ) -> None: ...
159     def getresponse(self) -> HTTPResponse: ...
160     def set_debuglevel(self, level: int) -> None: ...
161     def set_tunnel(self, host: str, port: int | None = ..., headers: Mapping[str, str] | None = ...) -> None: ...
162     def connect(self) -> None: ...
163     def close(self) -> None: ...
164     def putrequest(self, method: str, url: str, skip_host: bool = ..., skip_accept_encoding: bool = ...) -> None: ...
165     def putheader(self, header: str, *argument: str) -> None: ...
166     def endheaders(self, message_body: _DataType | None = ..., *, encode_chunked: bool = ...) -> None: ...
167     def send(self, data: _DataType) -> None: ...
168
169 class HTTPSConnection(HTTPConnection):
170     if sys.version_info >= (3, 7):
171         def __init__(
172             self,
173             host: str,
174             port: int | None = ...,
175             key_file: str | None = ...,
176             cert_file: str | None = ...,
177             timeout: float | None = ...,
178             source_address: tuple[str, int] | None = ...,
179             *,
180             context: ssl.SSLContext | None = ...,
181             check_hostname: bool | None = ...,
182             blocksize: int = ...,
183         ) -> None: ...
184     else:
185         def __init__(
186             self,
187             host: str,
188             port: int | None = ...,
189             key_file: str | None = ...,
190             cert_file: str | None = ...,
191             timeout: float | None = ...,
192             source_address: tuple[str, int] | None = ...,
193             *,
194             context: ssl.SSLContext | None = ...,
195             check_hostname: bool | None = ...,
196         ) -> None: ...
197
198 class HTTPException(Exception): ...
199
200 error = HTTPException
201
202 class NotConnected(HTTPException): ...
203 class InvalidURL(HTTPException): ...
204
205 class UnknownProtocol(HTTPException):
206     def __init__(self, version: str) -> None: ...
207
208 class UnknownTransferEncoding(HTTPException): ...
209 class UnimplementedFileMode(HTTPException): ...
210
211 class IncompleteRead(HTTPException):
212     def __init__(self, partial: bytes, expected: int | None = ...) -> None: ...
213     partial: bytes
214     expected: int | None
215
216 class ImproperConnectionState(HTTPException): ...
217 class CannotSendRequest(ImproperConnectionState): ...
218 class CannotSendHeader(ImproperConnectionState): ...
219 class ResponseNotReady(ImproperConnectionState): ...
220
221 class BadStatusLine(HTTPException):
222     def __init__(self, line: str) -> None: ...
223
224 class LineTooLong(HTTPException):
225     def __init__(self, line_type: str) -> None: ...
226
227 class RemoteDisconnected(ConnectionResetError, BadStatusLine): ...