Skip to content
Myr

Truckin' on

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 d7cf8bb · Browse files · 4 files+19 added−12 removed
This commit

State

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

Diff stats

4 files+19 added−12 removed

  • tests:+3 added−1 removed
  • other:+16 added−11 removed

4 files+19 added−12 removed

modified:httpcore/dispatch/http11.py+2 added-2 removed
52 unmodified lines
53 stream = options.get("stream", False)54 assert timeout is None or isinstance(timeout, TimeoutConfig)5556 #  Start sending the request.57 method = request.method.encode('ascii')58 target = request.url.full_path.encode('ascii')57 method = request.method.encode("ascii")58 target = request.url.full_path.encode("ascii")59 headers = request.headers.raw60 event = h11.Request(method=method, target=target, headers=headers)61 await self._send_event(event, timeout)62
86 unmodified lines
modified:httpcore/dispatch/http2.py+5 added-5 removed
60 unmodified lines
61 status_code = 20062 headers = []63 for k, v in event.headers:64 if k == b":status":65 status_code = int(v.decode('ascii', errors='ignore'))65 status_code = int(v.decode("ascii", errors="ignore"))66 elif not k.startswith(b":"):67 headers.append((k, v))6869 content = self.body_iter(stream_id, timeout)
27 unmodified lines
9798 async def send_headers(self, request: Request, timeout: OptionalTimeout) -> int:99 stream_id = self.h2_state.get_next_available_stream_id()100 headers = [101 (b":method", request.method.encode('ascii')),102 (b":authority", request.url.authority.encode('ascii')),103 (b":scheme", request.url.scheme.encode('ascii')),104 (b":path", request.url.full_path.encode('ascii')),101 (b":method", request.method.encode("ascii")),102 (b":authority", request.url.authority.encode("ascii")),103 (b":scheme", request.url.scheme.encode("ascii")),104 (b":path", request.url.full_path.encode("ascii")),105 ] + request.headers.raw106 self.h2_state.send_headers(stream_id, headers)107 data_to_send = self.h2_state.data_to_send()108 await self.writer.write(data_to_send, timeout)
48 unmodified lines
modified:httpcore/models.py+9 added-4 removed
507 unmodified lines
508 content_type = self.headers.get("Content-Type")509 if content_type is None:510 return None511512 parsed = cgi.parse_header(content_type)513 media_type, params = parsed[0], parsed[-1]514 if "charset" in params:515 return params["charset"].strip("'\"")516517 # RFC 2616 specifies that 'iso-8859-1' should be used as the default518 # for 'text/*' media types, if no charset is provided.519 # See: https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1515 parsed = cgi.parse_header(content_type)516 media_type, info = parsed[0], parsed[-1]517 default = "iso-8859-1" if media_type.startswith("text/") else None518 return info.get("charset", default)520 if media_type.startswith("text/"):521 return "iso-8859-1"522523 return None524525 @property526 def apparent_encoding(self) -> typing.Optional[str]:527 """528 Return the encoding, as it appears to autodetection.
89 unmodified lines
modified:tests/models/test_url.py+3 added-1 removed
14 unmodified lines
15 assert url.authority == "example.org:123"16 assert url.path == "/path/to/somewhere"17 assert url.query == "abc=123"18 assert url.fragment == "anchor"19 assert (19 assert repr(url) == "URL('https://example.org:123/path/to/somewhere?abc=123#anchor')"20 repr(url) == "URL('https://example.org:123/path/to/somewhere?abc=123#anchor')"21 )2223 new = url.copy_with(scheme="http")24 assert new == URL("http://example.org:123/path/to/somewhere?abc=123#anchor")25 assert new.scheme == "http"