Format: application/octet-stream
1 import ssl
2 from httplib import HTTPConnectionProtocol, HTTPResponse
3 from typing import Any, AnyStr, Callable, Dict, List, Mapping, Optional, Sequence, Text, Tuple, Type, Union
4 from urllib import addinfourl
5
6 _string = Union[str, unicode]
7
8 class URLError(IOError):
9 reason: Union[str, BaseException]
10
11 class HTTPError(URLError, addinfourl):
12 code: int
13 headers: Mapping[str, str]
14 def __init__(self, url, code: int, msg: str, hdrs: Mapping[str, str], fp: addinfourl) -> None: ...
15
16 class Request(object):
17 host: str
18 port: str
19 data: str
20 headers: Dict[str, str]
21 unverifiable: bool
22 type: Optional[str]
23 origin_req_host = ...
24 unredirected_hdrs: Dict[str, str]
25 def __init__(
26 self,
27 url: str,
28 data: Optional[str] = ...,
29 headers: Dict[str, str] = ...,
30 origin_req_host: Optional[str] = ...,
31 unverifiable: bool = ...,
32 ) -> None: ...
33 def __getattr__(self, attr): ...
34 def get_method(self) -> str: ...
35 def add_data(self, data) -> None: ...
36 def has_data(self) -> bool: ...
37 def get_data(self) -> str: ...
38 def get_full_url(self) -> str: ...
39 def get_type(self): ...
40 def get_host(self) -> str: ...
41 def get_selector(self): ...
42 def set_proxy(self, host, type) -> None: ...
43 def has_proxy(self) -> bool: ...
44 def get_origin_req_host(self) -> str: ...
45 def is_unverifiable(self) -> bool: ...
46 def add_header(self, key: str, val: str) -> None: ...
47 def add_unredirected_header(self, key: str, val: str) -> None: ...
48 def has_header(self, header_name: str) -> bool: ...
49 def get_header(self, header_name: str, default: Optional[str] = ...) -> str: ...
50 def header_items(self): ...
51
52 class OpenerDirector(object):
53 addheaders: List[Tuple[str, str]]
54 def add_handler(self, handler: BaseHandler) -> None: ...
55 def open(
56 self, fullurl: Union[Request, _string], data: Optional[_string] = ..., timeout: Optional[float] = ...
57 ) -> Optional[addinfourl]: ...
58 def error(self, proto: _string, *args: Any): ...
59
60 # Note that this type is somewhat a lie. The return *can* be None if
61 # a custom opener has been installed that fails to handle the request.
62 def urlopen(
63 url: Union[Request, _string],
64 data: Optional[_string] = ...,
65 timeout: Optional[float] = ...,
66 cafile: Optional[_string] = ...,
67 capath: Optional[_string] = ...,
68 cadefault: bool = ...,
69 context: Optional[ssl.SSLContext] = ...,
70 ) -> addinfourl: ...
71 def install_opener(opener: OpenerDirector) -> None: ...
72 def build_opener(*handlers: Union[BaseHandler, Type[BaseHandler]]) -> OpenerDirector: ...
73
74 class BaseHandler:
75 handler_order: int
76 parent: OpenerDirector
77 def add_parent(self, parent: OpenerDirector) -> None: ...
78 def close(self) -> None: ...
79 def __lt__(self, other: Any) -> bool: ...
80
81 class HTTPErrorProcessor(BaseHandler):
82 def http_response(self, request, response): ...
83
84 class HTTPDefaultErrorHandler(BaseHandler):
85 def http_error_default(self, req: Request, fp: addinfourl, code: int, msg: str, hdrs: Mapping[str, str]): ...
86
87 class HTTPRedirectHandler(BaseHandler):
88 max_repeats: int
89 max_redirections: int
90 def redirect_request(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str], newurl): ...
91 def http_error_301(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ...
92 def http_error_302(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ...
93 def http_error_303(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ...
94 def http_error_307(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ...
95 inf_msg: str
96
97 class ProxyHandler(BaseHandler):
98 proxies: Mapping[str, str]
99 def __init__(self, proxies: Optional[Mapping[str, str]] = ...): ...
100 def proxy_open(self, req: Request, proxy, type): ...
101
102 class HTTPPasswordMgr:
103 def __init__(self) -> None: ...
104 def add_password(self, realm: Optional[Text], uri: Union[Text, Sequence[Text]], user: Text, passwd: Text) -> None: ...
105 def find_user_password(self, realm: Optional[Text], authuri: Text) -> Tuple[Any, Any]: ...
106 def reduce_uri(self, uri: _string, default_port: bool = ...) -> Tuple[Any, Any]: ...
107 def is_suburi(self, base: _string, test: _string) -> bool: ...
108
109 class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr): ...
110
111 class AbstractBasicAuthHandler:
112 def __init__(self, password_mgr: Optional[HTTPPasswordMgr] = ...) -> None: ...
113 def add_password(self, realm: Optional[Text], uri: Union[Text, Sequence[Text]], user: Text, passwd: Text) -> None: ...
114 def http_error_auth_reqed(self, authreq, host, req: Request, headers: Mapping[str, str]): ...
115 def retry_http_basic_auth(self, host, req: Request, realm): ...
116
117 class HTTPBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
118 auth_header: str
119 def http_error_401(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ...
120
121 class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
122 auth_header: str
123 def http_error_407(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ...
124
125 class AbstractDigestAuthHandler:
126 def __init__(self, passwd: Optional[HTTPPasswordMgr] = ...) -> None: ...
127 def add_password(self, realm: Optional[Text], uri: Union[Text, Sequence[Text]], user: Text, passwd: Text) -> None: ...
128 def reset_retry_count(self) -> None: ...
129 def http_error_auth_reqed(self, auth_header: str, host: str, req: Request, headers: Mapping[str, str]) -> None: ...
130 def retry_http_digest_auth(self, req: Request, auth: str) -> Optional[HTTPResponse]: ...
131 def get_cnonce(self, nonce: str) -> str: ...
132 def get_authorization(self, req: Request, chal: Mapping[str, str]) -> str: ...
133 def get_algorithm_impls(self, algorithm: str) -> Tuple[Callable[[str], str], Callable[[str, str], str]]: ...
134 def get_entity_digest(self, data: Optional[bytes], chal: Mapping[str, str]) -> Optional[str]: ...
135
136 class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
137 auth_header: str
138 handler_order: int
139 def http_error_401(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ...
140
141 class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
142 auth_header: str
143 handler_order: int
144 def http_error_407(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ...
145
146 class AbstractHTTPHandler(BaseHandler): # undocumented
147 def __init__(self, debuglevel: int = ...) -> None: ...
148 def set_http_debuglevel(self, level: int) -> None: ...
149 def do_request_(self, request: Request) -> Request: ...
150 def do_open(self, http_class: HTTPConnectionProtocol, req: Request, **http_conn_args: Optional[Any]) -> addinfourl: ...
151
152 class HTTPHandler(AbstractHTTPHandler):
153 def http_open(self, req: Request) -> addinfourl: ...
154 def http_request(self, request: Request) -> Request: ... # undocumented
155
156 class HTTPSHandler(AbstractHTTPHandler):
157 def __init__(self, debuglevel: int = ..., context: Optional[ssl.SSLContext] = ...) -> None: ...
158 def https_open(self, req: Request) -> addinfourl: ...
159 def https_request(self, request: Request) -> Request: ... # undocumented
160
161 class HTTPCookieProcessor(BaseHandler):
162 def __init__(self, cookiejar: Optional[Any] = ...): ...
163 def http_request(self, request: Request): ...
164 def http_response(self, request: Request, response): ...
165
166 class UnknownHandler(BaseHandler):
167 def unknown_open(self, req: Request): ...
168
169 class FileHandler(BaseHandler):
170 def file_open(self, req: Request): ...
171 def get_names(self): ...
172 def open_local_file(self, req: Request): ...
173
174 class FTPHandler(BaseHandler):
175 def ftp_open(self, req: Request): ...
176 def connect_ftp(self, user, passwd, host, port, dirs, timeout): ...
177
178 class CacheFTPHandler(FTPHandler):
179 def __init__(self) -> None: ...
180 def setTimeout(self, t: Optional[float]): ...
181 def setMaxConns(self, m: int): ...
182 def check_cache(self): ...
183 def clear_cache(self): ...
184
185 def parse_http_list(s: AnyStr) -> List[AnyStr]: ...
186 def parse_keqv_list(l: List[AnyStr]) -> Dict[AnyStr, AnyStr]: ...
187