Format: application/octet-stream
⬇ Download File (5.8 KB)
   1  import mimetools
   2  import ssl
   3  from typing import Any, Dict, Optional, Protocol
   4  
   5  class HTTPMessage(mimetools.Message):
   6      def addcontinue(self, key: str, more: str) -> None: ...
   7      dict: Dict[str, str]
   8      def addheader(self, key: str, value: str) -> None: ...
   9      unixfrom: str
  10      headers: Any
  11      status: str
  12      seekable: bool
  13      def readheaders(self) -> None: ...
  14  
  15  class HTTPResponse:
  16      fp: Any
  17      debuglevel: Any
  18      strict: Any
  19      msg: Any
  20      version: Any
  21      status: Any
  22      reason: Any
  23      chunked: Any
  24      chunk_left: Any
  25      length: Any
  26      will_close: Any
  27      def __init__(
  28          self, sock, debuglevel: int = ..., strict: int = ..., method: Optional[Any] = ..., buffering: bool = ...
  29      ) -> None: ...
  30      def begin(self): ...
  31      def close(self): ...
  32      def isclosed(self): ...
  33      def read(self, amt: Optional[Any] = ...): ...
  34      def fileno(self): ...
  35      def getheader(self, name, default: Optional[Any] = ...): ...
  36      def getheaders(self): ...
  37  
  38  # This is an API stub only for HTTPConnection and HTTPSConnection, as used in
  39  # urllib2.AbstractHTTPHandler.do_open, which takes either the class
  40  # HTTPConnection or the class HTTPSConnection, *not* an instance of either
  41  # class. do_open does not use all of the parameters of HTTPConnection.__init__
  42  # or HTTPSConnection.__init__, so HTTPConnectionProtocol only implements the
  43  # parameters that do_open does use.
  44  class HTTPConnectionProtocol(Protocol):
  45      def __call__(self, host: str, timeout: int = ..., **http_con_args: Any) -> HTTPConnection: ...
  46  
  47  class HTTPConnection:
  48      response_class: Any
  49      default_port: Any
  50      auto_open: Any
  51      debuglevel: Any
  52      strict: Any
  53      timeout: Any
  54      source_address: Any
  55      sock: Any
  56      host: str = ...
  57      port: int = ...
  58      def __init__(
  59          self, host, port: Optional[Any] = ..., strict: Optional[Any] = ..., timeout=..., source_address: Optional[Any] = ...
  60      ) -> None: ...
  61      def set_tunnel(self, host, port: Optional[Any] = ..., headers: Optional[Any] = ...): ...
  62      def set_debuglevel(self, level): ...
  63      def connect(self): ...
  64      def close(self): ...
  65      def send(self, data): ...
  66      def putrequest(self, method, url, skip_host: int = ..., skip_accept_encoding: int = ...): ...
  67      def putheader(self, header, *values): ...
  68      def endheaders(self, message_body: Optional[Any] = ...): ...
  69      def request(self, method, url, body: Optional[Any] = ..., headers=...): ...
  70      def getresponse(self, buffering: bool = ...): ...
  71  
  72  class HTTP:
  73      debuglevel: Any
  74      def __init__(self, host: str = ..., port: Optional[Any] = ..., strict: Optional[Any] = ...) -> None: ...
  75      def connect(self, host: Optional[Any] = ..., port: Optional[Any] = ...): ...
  76      def getfile(self): ...
  77      file: Any
  78      headers: Any
  79      def getreply(self, buffering: bool = ...): ...
  80      def close(self): ...
  81  
  82  class HTTPSConnection(HTTPConnection):
  83      default_port: Any
  84      key_file: Any
  85      cert_file: Any
  86      def __init__(
  87          self,
  88          host,
  89          port: Optional[Any] = ...,
  90          key_file: Optional[Any] = ...,
  91          cert_file: Optional[Any] = ...,
  92          strict: Optional[Any] = ...,
  93          timeout=...,
  94          source_address: Optional[Any] = ...,
  95          context: Optional[Any] = ...,
  96      ) -> None: ...
  97      sock: Any
  98      def connect(self): ...
  99  
 100  class HTTPS(HTTP):
 101      key_file: Any
 102      cert_file: Any
 103      def __init__(
 104          self,
 105          host: str = ...,
 106          port: Optional[Any] = ...,
 107          key_file: Optional[Any] = ...,
 108          cert_file: Optional[Any] = ...,
 109          strict: Optional[Any] = ...,
 110          context: Optional[Any] = ...,
 111      ) -> None: ...
 112  
 113  class HTTPException(Exception): ...
 114  class NotConnected(HTTPException): ...
 115  class InvalidURL(HTTPException): ...
 116  
 117  class UnknownProtocol(HTTPException):
 118      args: Any
 119      version: Any
 120      def __init__(self, version) -> None: ...
 121  
 122  class UnknownTransferEncoding(HTTPException): ...
 123  class UnimplementedFileMode(HTTPException): ...
 124  
 125  class IncompleteRead(HTTPException):
 126      args: Any
 127      partial: Any
 128      expected: Any
 129      def __init__(self, partial, expected: Optional[Any] = ...) -> None: ...
 130  
 131  class ImproperConnectionState(HTTPException): ...
 132  class CannotSendRequest(ImproperConnectionState): ...
 133  class CannotSendHeader(ImproperConnectionState): ...
 134  class ResponseNotReady(ImproperConnectionState): ...
 135  
 136  class BadStatusLine(HTTPException):
 137      args: Any
 138      line: Any
 139      def __init__(self, line) -> None: ...
 140  
 141  class LineTooLong(HTTPException):
 142      def __init__(self, line_type) -> None: ...
 143  
 144  error: Any
 145  
 146  class LineAndFileWrapper:
 147      def __init__(self, line, file) -> None: ...
 148      def __getattr__(self, attr): ...
 149      def read(self, amt: Optional[Any] = ...): ...
 150      def readline(self): ...
 151      def readlines(self, size: Optional[Any] = ...): ...
 152  
 153  # Constants
 154  
 155  responses: Dict[int, str]
 156  
 157  HTTP_PORT: int
 158  HTTPS_PORT: int
 159  
 160  # status codes
 161  # informational
 162  CONTINUE: int
 163  SWITCHING_PROTOCOLS: int
 164  PROCESSING: int
 165  
 166  # successful
 167  OK: int
 168  CREATED: int
 169  ACCEPTED: int
 170  NON_AUTHORITATIVE_INFORMATION: int
 171  NO_CONTENT: int
 172  RESET_CONTENT: int
 173  PARTIAL_CONTENT: int
 174  MULTI_STATUS: int
 175  IM_USED: int
 176  
 177  # redirection
 178  MULTIPLE_CHOICES: int
 179  MOVED_PERMANENTLY: int
 180  FOUND: int
 181  SEE_OTHER: int
 182  NOT_MODIFIED: int
 183  USE_PROXY: int
 184  TEMPORARY_REDIRECT: int
 185  
 186  # client error
 187  BAD_REQUEST: int
 188  UNAUTHORIZED: int
 189  PAYMENT_REQUIRED: int
 190  FORBIDDEN: int
 191  NOT_FOUND: int
 192  METHOD_NOT_ALLOWED: int
 193  NOT_ACCEPTABLE: int
 194  PROXY_AUTHENTICATION_REQUIRED: int
 195  REQUEST_TIMEOUT: int
 196  CONFLICT: int
 197  GONE: int
 198  LENGTH_REQUIRED: int
 199  PRECONDITION_FAILED: int
 200  REQUEST_ENTITY_TOO_LARGE: int
 201  REQUEST_URI_TOO_LONG: int
 202  UNSUPPORTED_MEDIA_TYPE: int
 203  REQUESTED_RANGE_NOT_SATISFIABLE: int
 204  EXPECTATION_FAILED: int
 205  UNPROCESSABLE_ENTITY: int
 206  LOCKED: int
 207  FAILED_DEPENDENCY: int
 208  UPGRADE_REQUIRED: int
 209  
 210  # server error
 211  INTERNAL_SERVER_ERROR: int
 212  NOT_IMPLEMENTED: int
 213  BAD_GATEWAY: int
 214  SERVICE_UNAVAILABLE: int
 215  GATEWAY_TIMEOUT: int
 216  HTTP_VERSION_NOT_SUPPORTED: int
 217  INSUFFICIENT_STORAGE: int
 218  NOT_EXTENDED: int
 219