Add werkzeug.middleware (#3103)

HTTPConnection.timeout can be a float
This commit is contained in:
Sebastian Rittau
2019-07-24 17:51:55 +02:00
committed by Jelle Zijlstra
parent 8794e40d41
commit 0177dedc42
13 changed files with 213 additions and 116 deletions

View File

@@ -138,32 +138,33 @@ else:
# This is an API stub only for the class below, not a class itself.
# urllib.request uses it for a parameter.
class HTTPConnectionProtocol(Protocol):
class _HTTPConnectionProtocol(Protocol):
if sys.version_info >= (3, 7):
def __call__(self, host: str, port: Optional[int] = ...,
timeout: int = ...,
timeout: float = ...,
source_address: Optional[Tuple[str, int]] = ...,
blocksize: int = ...): ...
else:
def __call__(self, host: str, port: Optional[int] = ...,
timeout: int = ...,
timeout: float = ...,
source_address: Optional[Tuple[str, int]] = ...): ...
class HTTPConnection:
host: str = ...
port: int = ...
timeout: float
host: str
port: int
if sys.version_info >= (3, 7):
def __init__(
self,
host: str, port: Optional[int] = ...,
timeout: int = ...,
timeout: float = ...,
source_address: Optional[Tuple[str, int]] = ..., blocksize: int = ...
) -> None: ...
else:
def __init__(
self,
host: str, port: Optional[int] = ...,
timeout: int = ...,
timeout: float = ...,
source_address: Optional[Tuple[str, int]] = ...
) -> None: ...
if sys.version_info >= (3, 6):
@@ -196,7 +197,7 @@ class HTTPSConnection(HTTPConnection):
host: str, port: Optional[int] = ...,
key_file: Optional[str] = ...,
cert_file: Optional[str] = ...,
timeout: int = ...,
timeout: float = ...,
source_address: Optional[Tuple[str, int]] = ...,
*, context: Optional[ssl.SSLContext] = ...,
check_hostname: Optional[bool] = ...) -> None: ...

View File

@@ -4,7 +4,7 @@ from typing import (
Any, Callable, ClassVar, Dict, List, IO, Mapping, Optional, Sequence, Tuple,
TypeVar, Union, overload, NoReturn,
)
from http.client import HTTPResponse, HTTPMessage, HTTPConnectionProtocol
from http.client import HTTPResponse, HTTPMessage, _HTTPConnectionProtocol
from http.cookiejar import CookieJar
from email.message import Message
from urllib.response import addinfourl
@@ -162,7 +162,7 @@ class AbstractHTTPHandler(BaseHandler): # undocumented
def set_http_debuglevel(self, level: int) -> None: ...
def do_request_(self, request: Request) -> Request: ...
def do_open(self,
http_class: HTTPConnectionProtocol,
http_class: _HTTPConnectionProtocol,
req: Request,
**http_conn_args: Any) -> HTTPResponse: ...