8000 fix: correct headers= kwarg in HTTP[S]Connection by dimaqq · Pull Request #12704 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

fix: correct headers= kwarg in HTTP[S]Connection #12704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: correct headers= kwarg in HTTP[S]Connection
  • Loading branch information
dimaqq committed Sep 30, 2024
commit 12bcba3b502c1e5b0ba584d0e764313fb0040d86
10 changes: 8 additions & 2 deletions stdlib/http/client.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import io
import ssl
import sys
import types
from typing import Protocol
from _typeshed import ReadableBuffer, SupportsRead, SupportsReadline, WriteableBuffer
from collections.abc import Callable, Iterable, Iterator, Mapping
from socket import socket
Expand Down Expand Up @@ -35,6 +36,11 @@ _DataType: TypeAlias = SupportsRead[bytes] | Iterable[ReadableBuffer] | Readable
_T = TypeVar("_T")
_MessageT = TypeVar("_MessageT", bound=email.message.Message)

class _HasEncode(Protocol):
def encode(encoding: str) -> bytes: ...

_HeaderValue = ReadableBuffer | _HasEncode | int

HTTP_PORT: int
HTTPS_PORT: int

Expand Down Expand Up @@ -167,7 +173,7 @@ class HTTPConnection:
method: str,
url: str,
body: _DataType | str | None = None,
headers: Mapping[str, str] = {},
headers: Mapping[str, _HeaderValue] = {},
*,
encode_chunked: bool = False,
) -> None: ...
Expand All @@ -180,7 +186,7 @@ class HTTPConnection:
def connect(self) -> None: ...
def close(self) -> None: ...
def putrequest(self, method: str, url: str, skip_host: bool = False, skip_accept_encoding: bool = False) -> None: ...
def putheader(self, header: str | bytes, *argument: str | bytes) -> None: ...
def putheader(self, header: str | bytes, *argument: _HeaderValue) -> None: ...
def endheaders(self, message_body: _DataType | None = None, *, encode_chunked: bool = False) -> None: ...
def send(self, data: _DataType | str) -> None: ...

Expand Down
Loading
0