Skip to content
Myr

Rollin'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tom Christie · committed by Tom Christie · parent fab6fcd · Browse files · 16 files+432 added−67 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

16 files+432 added−67 removed

  • tests:+30 added−27 removed
  • other:+402 added−40 removed

16 files+432 added−67 removed

modified:httpcore/__init__.py+1 added-1 removed
12 unmodified lines
13 Timeout,14)15from .http2 import HTTP2Connection16from .http11 import HTTP11Connection17from .models import URL, Origin, Request, Response17from .models import URL, Headers, Origin, Request, Response18from .streams import BaseReader, BaseWriter, Protocol, Reader, Writer, connect19from .sync import SyncClient, SyncConnectionPool2021__version__ = "0.2.1"
modified:httpcore/adapters.py+1 added-1 removed
8 unmodified lines
9 self,10 method: str,11 url: typing.Union[str, URL],12 *,13 headers: typing.Sequence[typing.Tuple[bytes, bytes]] = (),13 headers: typing.List[typing.Tuple[bytes, bytes]] = [],14 body: typing.Union[bytes, typing.AsyncIterator[bytes]] = b"",15 **options: typing.Any,16 ) -> Response:17 request = Request(method, url, headers=headers, body=body)
23 unmodified lines
modified:httpcore/auth.py+1 added-1 removed
13 unmodified lines
14 async def send(self, request: Request, **options: typing.Any) -> Response:15 return await self.dispatch.send(request, **options)1617 async def close(self) -> None:18 self.dispatch.close()18 await self.dispatch.close()
modified:httpcore/client.py+3 added-3 removed
38 unmodified lines
39 method: str,40 url: typing.Union[str, URL],41 *,42 body: typing.Union[bytes, typing.AsyncIterator[bytes]] = b"",43 headers: typing.Sequence[typing.Tuple[bytes, bytes]] = (),43 headers: typing.List[typing.Tuple[bytes, bytes]] = [],44 stream: bool = False,45 allow_redirects: bool = True,46 ssl: typing.Optional[SSLConfig] = None,47 timeout: typing.Optional[TimeoutConfig] = None,
12 unmodified lines
60 async def get(61 self,62 url: typing.Union[str, URL],63 *,64 headers: typing.Sequence[typing.Tuple[bytes, bytes]] = (),64 headers: typing.List[typing.Tuple[bytes, bytes]] = [],65 stream: bool = False,66 ssl: typing.Optional[SSLConfig] = None,67 timeout: typing.Optional[TimeoutConfig] = None,68 ) -> Response:
5 unmodified lines
74 self,75 url: typing.Union[str, URL],76 *,77 body: typing.Union[bytes, typing.AsyncIterator[bytes]] = b"",78 headers: typing.Sequence[typing.Tuple[bytes, bytes]] = (),78 headers: typing.List[typing.Tuple[bytes, bytes]] = [],79 stream: bool = False,80 ssl: typing.Optional[SSLConfig] = None,81 timeout: typing.Optional[TimeoutConfig] = None,82 ) -> Response:
42 unmodified lines
modified:httpcore/cookies.py+1 added-1 removed
13 unmodified lines
14 async def send(self, request: Request, **options: typing.Any) -> Response:15 return await self.dispatch.send(request, **options)1617 async def close(self) -> None:18 self.dispatch.close()18 await self.dispatch.close()
modified:httpcore/decoders.py+7 added-7 removed
108 unmodified lines
109 return data110111112SUPPORTED_DECODERS = {113 b"identity": IdentityDecoder,114 b"deflate": DeflateDecoder,115 b"gzip": GZipDecoder,116 b"br": BrotliDecoder,113 "identity": IdentityDecoder,114 "deflate": DeflateDecoder,115 "gzip": GZipDecoder,116 "br": BrotliDecoder,117}118119120if brotli is None:121 SUPPORTED_DECODERS.pop(b"br") # pragma: nocover121 SUPPORTED_DECODERS.pop("br") # pragma: nocover122123124ACCEPT_ENCODING = b", ".join(125 [key for key in SUPPORTED_DECODERS.keys() if key != b"identity"]124ACCEPT_ENCODING = ", ".join(125 [key for key in SUPPORTED_DECODERS.keys() if key != "identity"]126)
modified:httpcore/exceptions.py+5 added
50 unmodified lines
51 """52 Attempted to read or stream response content, but the request has been53 closed without loading the body.54 """555657class InvalidURL(Exception):58 """59 """
modified:httpcore/http11.py+1 added-1 removed
49 unmodified lines
5051 #  Start sending the request.52 method = request.method.encode()53 target = request.url.full_path54 headers = request.headers54 headers = request.headers.raw55 event = h11.Request(method=method, target=target, headers=headers)56 await self._send_event(event, timeout)5758 # Send the request body.
84 unmodified lines
modified:httpcore/http2.py+1 added-1 removed
94 unmodified lines
95 (b":method", request.method.encode()),96 (b":authority", request.url.hostname.encode()),97 (b":scheme", request.url.scheme.encode()),98 (b":path", request.url.full_path.encode()),99 ] + request.headers99 ] + request.headers.raw100 self.h2_state.send_headers(stream_id, headers)101 data_to_send = self.h2_state.data_to_send()102 await self.writer.write(data_to_send, timeout)103 return stream_id
47 unmodified lines
modified:httpcore/models.py+130 added-19 removed
38 unmodified lines
39 def query(self) -> str:40 return self.components.query4142 @property43 def fragment(self) -> str:44 return self.components.fragment4546 @property47 def hostname(self) -> str:48 return self.components.hostname4950 @property
39 unmodified lines
90 def __hash__(self) -> int:91 return hash((self.is_ssl, self.hostname, self.port))929394class Headers(typing.MutableMapping[str, str]):95 """96 A case-insensitive multidict.97 """9899 def __init__(self, headers: typing.List[typing.Tuple[bytes, bytes]]) -> None:100 self._list = [(k.lower(), v) for k, v in headers]101102 @property103 def raw(self) -> typing.List[typing.Tuple[bytes, bytes]]:104 return self._list105106 def keys(self) -> typing.List[str]: # type: ignore107 return [key.decode("latin-1") for key, value in self._list]108109 def values(self) -> typing.List[str]: # type: ignore110 return [value.decode("latin-1") for key, value in self._list]111112 def items(self) -> typing.List[typing.Tuple[str, str]]: # type: ignore113 return [114 (key.decode("latin-1"), value.decode("latin-1"))115 for key, value in self._list116 ]117118 def get(self, key: str, default: typing.Any = None) -> typing.Any:119 try:120 return self[key]121 except KeyError:122 return default123124 def getlist(self, key: str) -> typing.List[str]:125 get_header_key = key.lower().encode("latin-1")126 return [127 item_value.decode("latin-1")128 for item_key, item_value in self._list129 if item_key == get_header_key130 ]131132 def __getitem__(self, key: str) -> str:133 get_header_key = key.lower().encode("latin-1")134 for header_key, header_value in self._list:135 if header_key == get_header_key:136 return header_value.decode("latin-1")137 raise KeyError(key)138139 def __setitem__(self, key: str, value: str) -> None:140 """141 Set the header `key` to `value`, removing any duplicate entries.142 Retains insertion order.143 """144 set_key = key.lower().encode("latin-1")145 set_value = value.encode("latin-1")146147 found_indexes = []148 for idx, (item_key, item_value) in enumerate(self._list):149 if item_key == set_key:150 found_indexes.append(idx)151152 for idx in reversed(found_indexes[1:]):153 del self._list[idx]154155 if found_indexes:156 idx = found_indexes[0]157 self._list[idx] = (set_key, set_value)158 else:159 self._list.append((set_key, set_value))160161 def __delitem__(self, key: str) -> None:162 """163 Remove the header `key`.164 """165 del_key = key.lower().encode("latin-1")166167 pop_indexes = []168 for idx, (item_key, item_value) in enumerate(self._list):169 if item_key == del_key:170 pop_indexes.append(idx)171172 for idx in reversed(pop_indexes):173 del self._list[idx]174175 def __contains__(self, key: typing.Any) -> bool:176 get_header_key = key.lower().encode("latin-1")177 for header_key, header_value in self._list:178 if header_key == get_header_key:179 return True180 return False181182 def __iter__(self) -> typing.Iterator[typing.Any]:183 return iter(self.keys())184185 def __len__(self) -> int:186 return len(self._list)187188 def __eq__(self, other: typing.Any) -> bool:189 if not isinstance(other, Headers):190 return False191 return sorted(self._list) == sorted(other._list)192193 def __repr__(self) -> str:194 class_name = self.__class__.__name__195 as_dict = dict(self.items())196 if len(as_dict) == len(self):197 return f"{class_name}({as_dict!r})"198 return f"{class_name}(raw={self.raw!r})"199200201class Request:202 def __init__(203 self,204 method: str,205 url: typing.Union[str, URL],206 *,96 headers: typing.Sequence[typing.Tuple[bytes, bytes]] = (),207 headers: typing.List[typing.Tuple[bytes, bytes]] = [],208 body: typing.Union[bytes, typing.AsyncIterator[bytes]] = b"",209 ):210 self.method = method.upper()211 self.url = URL(url) if isinstance(url, str) else url101 self.headers = list(headers)212 if isinstance(body, bytes):213 self.is_streaming = False214 self.body = body215 else:216 self.is_streaming = True217 self.body_aiter = body108 self.headers = self._auto_headers() + self.headers218 self.headers = self.build_headers(headers)219110 def _auto_headers(self) -> typing.List[typing.Tuple[bytes, bytes]]:220 def build_headers(221 self, init_headers: typing.List[typing.Tuple[bytes, bytes]]222 ) -> Headers:223 has_host = False224 has_content_length = False225 has_accept_encoding = False226115 for header, value in self.headers:227 for header, value in init_headers:228 header = header.strip().lower()229 if header == b"host":230 has_host = True231 elif header in (b"content-length", b"transfer-encoding"):232 has_content_length = True233 elif header == b"accept-encoding":234 has_accept_encoding = True235124 headers = [] # type: typing.List[typing.Tuple[bytes, bytes]]236 auto_headers = [] # type: typing.List[typing.Tuple[bytes, bytes]]237238 if not has_host:127 headers.append((b"host", self.url.netloc.encode("ascii")))239 auto_headers.append((b"host", self.url.netloc.encode("ascii")))240 if not has_content_length:241 if self.is_streaming:130 headers.append((b"transfer-encoding", b"chunked"))242 auto_headers.append((b"transfer-encoding", b"chunked"))243 elif self.body:244 content_length = str(len(self.body)).encode()133 headers.append((b"content-length", content_length))245 auto_headers.append((b"content-length", content_length))246 if not has_accept_encoding:135 headers.append((b"accept-encoding", ACCEPT_ENCODING))247 auto_headers.append((b"accept-encoding", ACCEPT_ENCODING.encode()))248137 return headers249 return Headers(auto_headers + init_headers)250251 async def stream(self) -> typing.AsyncIterator[bytes]:252 if self.is_streaming:253 async for part in self.body_aiter:
8 unmodified lines
262 status_code: int,263 *,264 reason: typing.Optional[str] = None,265 protocol: typing.Optional[str] = None,154 headers: typing.Sequence[typing.Tuple[bytes, bytes]] = (),266 headers: typing.List[typing.Tuple[bytes, bytes]] = [],267 body: typing.Union[bytes, typing.AsyncIterator[bytes]] = b"",268 on_close: typing.Callable = None,269 ):270 self.status_code = status_code
4 unmodified lines
275 self.reason = ""276 else:277 self.reason = reason278 self.protocol = protocol167 self.headers = list(headers)279 self.headers = Headers(headers)280 self.on_close = on_close281 self.is_closed = False282 self.is_streamed = False283284 decoders = [] # type: typing.List[Decoder]173 for header, value in self.headers:174 if header.strip().lower() == b"content-encoding":175 for part in value.split(b","):176 part = part.strip().lower()177 decoder_cls = SUPPORTED_DECODERS[part]178 decoders.append(decoder_cls())285 value = self.headers.get("content-encoding", "identity")286 for part in value.split(","):287 part = part.strip().lower()288 decoder_cls = SUPPORTED_DECODERS[part]289 decoders.append(decoder_cls())290291 if len(decoders) == 0:292 self.decoder = IdentityDecoder() # type: Decoder293 elif len(decoders) == 1:
59 unmodified lines
modified:httpcore/redirects.py+53 added-2 removed
1import typing2from urllib.parse import urljoin, urlparse34from .adapters import Adapter5from .exceptions import TooManyRedirects5from .models import Request, Response6from .models import URL, Request, Response7from .status_codes import codes8from .utils import requote_uri91011class RedirectAdapter(Adapter):12 def __init__(self, dispatch: Adapter, max_redirects: int):
18 unmodified lines
3132 return response3334 async def close(self) -> None:32 self.dispatch.close()35 await self.dispatch.close()3637 def build_redirect_request(self, request: Request, response: Response) -> Request:38 method = self.redirect_method(request, response)39 url = self.redirect_url(request, response)40 raise NotImplementedError()4142 def redirect_method(self, request: Request, response: Response) -> str:43 """44 When being redirected we may want to change the method of the request45 based on certain specs or browser behavior.46 """47 method = request.method4849 # https://tools.ietf.org/html/rfc7231#section-6.4.450 if response.status_code == codes["see_other"] and method != "HEAD":51 method = "GET"5253 # Do what the browsers do, despite standards...54 # First, turn 302s into GETs.55 if response.status_code == codes["found"] and method != "HEAD":56 method = "GET"5758 # Second, if a POST is responded to with a 301, turn it into a GET.59 # This bizarre behaviour is explained in Issue 1704.60 if response.status_code == codes["moved"] and method == "POST":61 method = "GET"6263 return method6465 def redirect_url(self, request: Request, response: Response) -> URL:66 location = response.headers["Location"]6768 # Handle redirection without scheme (see: RFC 1808 Section 4)69 if location.startswith("//"):70 location = f"{request.url.scheme}:{location}"7172 # Normalize url case and attach previous fragment if needed (RFC 7231 7.1.2)73 parsed = urlparse(location)74 if parsed.fragment == "" and request.url.fragment:75 parsed = parsed._replace(fragment=request.url.fragment)76 url = parsed.geturl()7778 # Facilitate relative 'location' headers, as allowed by RFC 7231.79 # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')80 # Compliant with RFC3986, we percent encode the url.81 if not parsed.netloc:82 url = urljoin(str(request.url), requote_uri(url))83 else:84 url = requote_uri(url)8586 return URL(url)
added:httpcore/status_codes.py+123 added
1"""2The ``codes`` object defines a mapping from common names for HTTP statuses3to their numerical codes, accessible either as attributes or as dictionary4items.5>>> requests.codes['temporary_redirect']63077>>> requests.codes.teapot84189Some codes have multiple names, and both upper- and lower-case versions of10the names are allowed. For example, ``codes.ok``, ``codes.OK``, and11``codes.okay`` all correspond to the HTTP status code 200.12"""1314import typing1516from .structures import LookupDict1718_codes = {19 # Informational.20 100: ("continue",),21 101: ("switching_protocols",),22 102: ("processing",),23 103: ("checkpoint",),24 122: ("uri_too_long", "request_uri_too_long"),25 200: ("ok", "okay", "all_ok", "all_okay", "all_good", "\\o/", "✓"),26 201: ("created",),27 202: ("accepted",),28 203: ("non_authoritative_info", "non_authoritative_information"),29 204: ("no_content",),30 205: ("reset_content", "reset"),31 206: ("partial_content", "partial"),32 207: ("multi_status", "multiple_status", "multi_stati", "multiple_stati"),33 208: ("already_reported",),34 226: ("im_used",),35 # Redirection.36 300: ("multiple_choices",),37 301: ("moved_permanently", "moved", "\\o-"),38 302: ("found",),39 303: ("see_other", "other"),40 304: ("not_modified",),41 305: ("use_proxy",),42 306: ("switch_proxy",),43 307: ("temporary_redirect", "temporary_moved", "temporary"),44 308: (45 "permanent_redirect",46 "resume_incomplete",47 "resume",48 ), # These 2 to be removed in 3.049 # Client Error.50 400: ("bad_request", "bad"),51 401: ("unauthorized",),52 402: ("payment_required", "payment"),53 403: ("forbidden",),54 404: ("not_found", "-o-"),55 405: ("method_not_allowed", "not_allowed"),56 406: ("not_acceptable",),57 407: ("proxy_authentication_required", "proxy_auth", "proxy_authentication"),58 408: ("request_timeout", "timeout"),59 409: ("conflict",),60 410: ("gone",),61 411: ("length_required",),62 412: ("precondition_failed", "precondition"),63 413: ("request_entity_too_large",),64 414: ("request_uri_too_large",),65 415: ("unsupported_media_type", "unsupported_media", "media_type"),66 416: (67 "requested_range_not_satisfiable",68 "requested_range",69 "range_not_satisfiable",70 ),71 417: ("expectation_failed",),72 418: ("im_a_teapot", "teapot", "i_am_a_teapot"),73 421: ("misdirected_request",),74 422: ("unprocessable_entity", "unprocessable"),75 423: ("locked",),76 424: ("failed_dependency", "dependency"),77 425: ("unordered_collection", "unordered"),78 426: ("upgrade_required", "upgrade"),79 428: ("precondition_required", "precondition"),80 429: ("too_many_requests", "too_many"),81 431: ("header_fields_too_large", "fields_too_large"),82 444: ("no_response", "none"),83 449: ("retry_with", "retry"),84 450: ("blocked_by_windows_parental_controls", "parental_controls"),85 451: ("unavailable_for_legal_reasons", "legal_reasons"),86 499: ("client_closed_request",),87 # Server Error.88 500: ("internal_server_error", "server_error", "/o\\", "✗"),89 501: ("not_implemented",),90 502: ("bad_gateway",),91 503: ("service_unavailable", "unavailable"),92 504: ("gateway_timeout",),93 505: ("http_version_not_supported", "http_version"),94 506: ("variant_also_negotiates",),95 507: ("insufficient_storage",),96 509: ("bandwidth_limit_exceeded", "bandwidth"),97 510: ("not_extended",),98 511: ("network_authentication_required", "network_auth", "network_authentication"),99} # type: typing.Dict[int, typing.Sequence[str]]100101codes = LookupDict(name="status_codes")102103104def _init() -> None:105 for code, titles in _codes.items():106 for title in titles:107 setattr(codes, title, code)108 if not title.startswith(("\\", "/")):109 setattr(codes, title.upper(), code)110111 def doc(code: int) -> str:112 names = ", ".join("``%s``" % n for n in _codes[code])113 return "* %d: %s" % (code, names)114115 global __doc__116 __doc__ = (117 __doc__ + "\n" + "\n".join(doc(code) for code in sorted(_codes))118 if __doc__ is not None119 else None120 )121122123_init()
added:httpcore/structures.py+20 added
1import typing234class LookupDict(dict):5 """Dictionary lookup object."""67 def __init__(self, name: str = None) -> None:8 self.name = name9 super(LookupDict, self).__init__()1011 def __repr__(self) -> str:12 return "<lookup '%s'>" % (self.name)1314 def __getitem__(self, key: typing.Any) -> typing.Any:15 # We allow fall-through here, so values default to None1617 return self.__dict__.get(key, None)1819 def get(self, key: typing.Any, default: typing.Any = None) -> typing.Any:20 return self.__dict__.get(key, default)
modified:httpcore/sync.py+3 added-3 removed
3 unmodified lines
45from .adapters import Adapter6from .config import SSLConfig, TimeoutConfig7from .connection_pool import ConnectionPool8from .models import URL, Response8from .models import URL, Headers, Response91011class SyncResponse:12 def __init__(self, response: Response, loop: asyncio.AbstractEventLoop):
8 unmodified lines
21 def reason(self) -> str:22 return self._response.reason2324 @property25 def headers(self) -> typing.List[typing.Tuple[bytes, bytes]]:25 def headers(self) -> Headers:26 return self._response.headers2728 @property29 def body(self) -> bytes:
23 unmodified lines
53 self,54 method: str,55 url: typing.Union[str, URL],56 *,57 headers: typing.Sequence[typing.Tuple[bytes, bytes]] = (),57 headers: typing.List[typing.Tuple[bytes, bytes]] = [],58 body: typing.Union[bytes, typing.AsyncIterator[bytes]] = b"",59 **options: typing.Any60 ) -> SyncResponse:61 response = self._loop.run_until_complete(
22 unmodified lines
added:httpcore/utils.py+52 added
1from urllib.parse import quote23from .exceptions import InvalidURL45# The unreserved URI characters (RFC 3986)6UNRESERVED_SET = frozenset(7 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + "0123456789-._~"8)91011def unquote_unreserved(uri: str) -> str:12 """Un-escape any percent-escape sequences in a URI that are unreserved13 characters. This leaves all reserved, illegal and non-ASCII bytes encoded.14 :rtype: str15 """16 parts = uri.split("%")17 for i in range(1, len(parts)):18 h = parts[i][0:2]19 if len(h) == 2 and h.isalnum():20 try:21 c = chr(int(h, 16))22 except ValueError:23 raise InvalidURL("Invalid percent-escape sequence: '%s'" % h)2425 if c in UNRESERVED_SET:26 parts[i] = c + parts[i][2:]27 else:28 parts[i] = "%" + parts[i]29 else:30 parts[i] = "%" + parts[i]31 return "".join(parts)323334def requote_uri(uri: str) -> str:35 """36 Re-quote the given URI.3738 This function passes the given URI through an unquote/quote cycle to39 ensure that it is fully and consistently quoted.40 """41 safe_with_percent = "!#$%&'()*+,/:;=?@[]~"42 safe_without_percent = "!#$&'()*+,/:;=?@[]~"43 try:44 # Unquote only the unreserved characters45 # Then quote only illegal characters (do not quote reserved,46 # unreserved, or '%')47 return quote(unquote_unreserved(uri), safe=safe_with_percent)48 except InvalidURL:49 # We couldn't unquote the given URI, so let's try quoting it, but50 # there may be unquoted '%'s in the URI. We need to make sure they're51 # properly quoted so they do not cause issues elsewhere.52 return quote(uri, safe=safe_without_percent)
modified:tests/test_requests.py+30 added-27 removed
3 unmodified lines
456def test_host_header():7 request = httpcore.Request("GET", "http://example.org")8 assert request.headers == [9 (b"host", b"example.org"),10 (b"accept-encoding", b"deflate, gzip, br"),11 ]8 assert request.headers == httpcore.Headers(9 [(b"host", b"example.org"), (b"accept-encoding", b"deflate, gzip, br")]10 )111213def test_content_length_header():14 request = httpcore.Request("POST", "http://example.org", body=b"test 123")15 assert request.headers == httpcore.Headers(16 assert request.headers == [17 (b"host", b"example.org"),18 (b"content-length", b"8"),19 (b"accept-encoding", b"deflate, gzip, br"),20 ]16 [17 (b"host", b"example.org"),18 (b"content-length", b"8"),19 (b"accept-encoding", b"deflate, gzip, br"),20 ]21 )222324def test_transfer_encoding_header():25 async def streaming_body(data):
1 unmodified line
2728 body = streaming_body(b"test 123")2930 request = httpcore.Request("POST", "http://example.org", body=body)31 assert request.headers == httpcore.Headers(30 assert request.headers == [31 (b"host", b"example.org"),32 (b"transfer-encoding", b"chunked"),33 (b"accept-encoding", b"deflate, gzip, br"),34 ]32 [33 (b"host", b"example.org"),34 (b"transfer-encoding", b"chunked"),35 (b"accept-encoding", b"deflate, gzip, br"),36 ]37 )383940def test_override_host_header():41 headers = [(b"host", b"1.2.3.4:80")]4243 request = httpcore.Request("GET", "http://example.org", headers=headers)41 assert request.headers == [42 (b"accept-encoding", b"deflate, gzip, br"),43 (b"host", b"1.2.3.4:80"),44 ]44 assert request.headers == httpcore.Headers(45 [(b"accept-encoding", b"deflate, gzip, br"), (b"host", b"1.2.3.4:80")]46 )474849def test_override_accept_encoding_header():50 headers = [(b"accept-encoding", b"identity")]5152 request = httpcore.Request("GET", "http://example.org", headers=headers)51 assert request.headers == [52 (b"host", b"example.org"),53 (b"accept-encoding", b"identity"),54 ]53 assert request.headers == httpcore.Headers(54 [(b"host", b"example.org"), (b"accept-encoding", b"identity")]55 )565758def test_override_content_length_header():59 async def streaming_body(data):
2 unmodified lines
62 body = streaming_body(b"test 123")63 headers = [(b"content-length", b"8")]6465 request = httpcore.Request("POST", "http://example.org", body=body, headers=headers)66 assert request.headers == httpcore.Headers(65 assert request.headers == [66 (b"host", b"example.org"),67 (b"accept-encoding", b"deflate, gzip, br"),68 (b"content-length", b"8"),69 ]67 [68 (b"host", b"example.org"),69 (b"accept-encoding", b"deflate, gzip, br"),70 (b"content-length", b"8"),71 ]72 )737475def test_url():76 request = httpcore.Request("GET", "http://example.org")
19 unmodified lines