Skip to content
Myr

Fix typos (#1968)

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

authored by Kian Meng, Ang · committed by GitHub · parent 3c5884e · Browse files · 12 files+24 added−24 removed
This commit

State

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

Diff stats

12 files+24 added−24 removed

  • tests:+2 added−2 removed
  • other:+22 added−22 removed

12 files+24 added−24 removed

modified:docs/advanced.md+1 added-1 removed
24 unmodified lines
25#### Extra features2627`Client` instances also support features that aren't available at the top-level API, such as:2829- Cookie persistance across requests.29- Cookie persistence across requests.30- Applying configuration across all outgoing requests.31- Sending requests through HTTP proxies.32- Using [HTTP/2](http2.md).33
1158 unmodified lines
modified:docs/compatibility.md+2 added-2 removed
14 unmodified lines
15You can still enable behaviour to automatically follow redirects, but you need to16do so explicitly...1718```python19respose = client.get(url, follow_redirects=True)19response = client.get(url, follow_redirects=True)20```2122Or else instantiate a client, with redirect following enabled by default...23
72 unmodified lines
96opened in text mode.9798## Content encoding99100HTTPX uses `utf-8` for encoding `str` request bodies. For example, when using `content=<str>` the request body will be encoded to `utf-8` before being sent over the wire. This differs from Requests which uses `latin1`. If you need an explicit encoding, pass encoded bytes explictly, e.g. `content=<str>.encode("latin1")`.100HTTPX uses `utf-8` for encoding `str` request bodies. For example, when using `content=<str>` the request body will be encoded to `utf-8` before being sent over the wire. This differs from Requests which uses `latin1`. If you need an explicit encoding, pass encoded bytes explicitly, e.g. `content=<str>.encode("latin1")`.101For response bodies, assuming the server didn't send an explicit encoding then HTTPX will do its best to figure out an appropriate encoding. HTTPX makes a guess at the encoding to use for decoding the response using `charset_normalizer`. Fallback to that or any content with less than 32 octets will be decoded using `utf-8` with the `error="replace"` decoder strategy.102103## Cookies104
106 unmodified lines
modified:httpx/_transports/base.py+1 added-1 removed
23 unmodified lines
24 Send a single HTTP request and return a response.2526 At this layer of API we're simply using plain primitives. No `Request` or27 `Response` models, no fancy `URL` or `Header` handling. This strict point28 of cut-off provides a clear design seperation between the HTTPX API,28 of cut-off provides a clear design separation between the HTTPX API,29 and the low-level network handling.3031 Developers shouldn't typically ever need to call into this API directly,32 since the Client class provides all the higher level user-facing API
81 unmodified lines
modified:httpx/_transports/default.py+1 added-1 removed
7 unmodified lines
8* retries: int910Example usages...1112# Disable HTTP/2 on a single specfic domain.12# Disable HTTP/2 on a single specific domain.13mounts = {14 "all://": httpx.HTTPTransport(http2=True),15 "all://*example.org": httpx.HTTPTransport()16}
287 unmodified lines
modified:httpx/_client.py+2 added-2 removed
1273 unmodified lines
1274 transport.__exit__(exc_type, exc_value, traceback)12751276 def __del__(self) -> None:1277 # We use 'getattr' here, to manage the case where '__del__()' is called1278 # on a partically initiallized instance that raised an exception during1278 # on a partially initiallized instance that raised an exception during1279 # the call to '__init__()'.1280 if getattr(self, "_state", None) == ClientState.OPENED: # noqa: B0091281 self.close()1282
702 unmodified lines
1985 await proxy.__aexit__(exc_type, exc_value, traceback)19861987 def __del__(self) -> None:1988 # We use 'getattr' here, to manage the case where '__del__()' is called1989 # on a partically initiallized instance that raised an exception during1989 # on a partially initiallized instance that raised an exception during1990 # the call to '__init__()'.1991 if getattr(self, "_state", None) == ClientState.OPENED: # noqa: B0091992 # Unlike the sync case, we cannot silently close the client when1993 # it is garbage collected, because `.aclose()` is an async operation,
23 unmodified lines
modified:httpx/_content.py+1 added-1 removed
186 unmodified lines
187 Handles encoding the given `content`, `data`, `files`, and `json`,188 returning a two-tuple of (<headers>, <stream>).189 """190 if data is not None and not isinstance(data, dict):191 # We prefer to seperate `content=<bytes|str|byte iterator|bytes aiterator>`191 # We prefer to separate `content=<bytes|str|byte iterator|bytes aiterator>`192 # for raw request content, and `data=<form data>` for url encoded or193 # multipart form content.194 #195 # However for compat with requests, we *do* still support
38 unmodified lines
modified:httpx/_models.py+8 added-8 removed
325 unmodified lines
326 def query(self) -> bytes:327 """328 The URL query string, as raw bytes, excluding the leading b"?".329330 This is neccessarily a bytewise interface, because we cannot330 This is necessarily a bytewise interface, because we cannot331 perform URL decoding of this representation until we've parsed332 the keys and values into a QueryParams instance.333334 For example:
129 unmodified lines
464 host = kwargs.pop("host", self.host) or ""465 port = kwargs.pop("port", self.port)466467 if host and ":" in host and host[0] != "[":468 # IPv6 addresses need to be escaped within sqaure brackets.468 # IPv6 addresses need to be escaped within square brackets.469 host = f"[{host}]"470471 kwargs["netloc"] = (472 f"{host}:{port}".encode("ascii")
433 unmodified lines
906907 def items(self) -> typing.ItemsView[str, str]:908 """909 Return `(key, value)` items of headers. Concatenate headers910 into a single comma seperated value when a key occurs multiple times.910 into a single comma separated value when a key occurs multiple times.911 """912 values_dict: typing.Dict[str, str] = {}913 for _, key, value in self._list:914 str_key = key.decode(self.encoding)
6 unmodified lines
921922 def multi_items(self) -> typing.List[typing.Tuple[str, str]]:923 """924 Return a list of `(key, value)` pairs of headers. Allow multiple925 occurences of the same key without concatenating into a single926 comma seperated value.925 occurrences of the same key without concatenating into a single926 comma separated value.927 """928 return [929 (key.decode(self.encoding), value.decode(self.encoding))930 for _, key, value in self._list931 ]932933 def get(self, key: str, default: typing.Any = None) -> typing.Any:934 """935 Return a header value. If multiple occurences of the header occur935 Return a header value. If multiple occurrences of the header occur936 then concatenate them together with commas.937 """938 try:939 return self[key]
2 unmodified lines
942943 def get_list(self, key: str, split_commas: bool = False) -> typing.List[str]:944 """945 Return a list of all header values for a given key.946 If `split_commas=True` is passed, then any comma seperated header946 If `split_commas=True` is passed, then any comma separated header947 values are split into multiple return strings.948 """949 get_header_key = key.lower().encode(self.encoding)950
413 unmodified lines
13641365 @property1366 def apparent_encoding(self) -> typing.Optional[str]:1367 """1368 Return the encoding, as detemined by `charset_normalizer`.1368 Return the encoding, as determined by `charset_normalizer`.1369 """1370 content = getattr(self, "_content", b"")1371 if len(content) < 32:1372 # charset_normalizer will issue warnings if we run it with
573 unmodified lines
modified:httpx/_types.py+1 added-1 removed
117 unmodified lines
118 """119120 def read(self) -> bytes:121 """122 Simple cases can use `.read()` as a convience method for consuming122 Simple cases can use `.read()` as a convenience method for consuming123 the entire stream and then closing it.124125 Example:126
24 unmodified lines
modified:httpx/_utils.py+1 added-1 removed
303 unmodified lines
304 # See https://curl.haxx.se/libcurl/c/CURLOPT_NOPROXY.html for details305 # on how names in `NO_PROXY` are handled.306 if hostname == "*":307 # If NO_PROXY=* is used or if "*" occurs as any one of the comma308 # seperated hostnames, then we should just bypass any information308 # separated hostnames, then we should just bypass any information309 # from HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, and always ignore310 # proxies.311 return {}312 elif hostname:
196 unmodified lines
modified:tests/client/test_proxies.py+1 added-1 removed
223 unmodified lines
224 "https://www.example1.com",225 {"ALL_PROXY": "http://localhost:123", "NO_PROXY": ".example1.com"},226 None,227 ),228 # Proxied, because NO_PROXY subdomains only match if "." seperated.228 # Proxied, because NO_PROXY subdomains only match if "." separated.229 (230 "https://www.example2.com",231 {"ALL_PROXY": "http://localhost:123", "NO_PROXY": "ample2.com"},232 "http://localhost:123",
40 unmodified lines
modified:tests/test_utils.py+1 added-1 removed
69 unmodified lines
707172def test_get_netrc_unknown():73 netrc_info = NetRCInfo([str(FIXTURES_DIR / ".netrc")])74 assert netrc_info.get_credentials("nonexistant.org") is None74 assert netrc_info.get_credentials("nonexistent.org") is None757677@pytest.mark.parametrize(78 "value, expected",
181 unmodified lines
modified:CHANGELOG.md+4 added-4 removed
90 unmodified lines
9192### Fixed9394* `response.iter_bytes()` no longer raises a ValueError when called on a response with no content. (Pull #1827)95* The `'wsgi.error'` configuration now defaults to `sys.stderr`, and is corrected to be a `TextIO` interface, not a `BytesIO` interface. Additionally, the WSGITransport now accepts a `wsgi_error` confguration. (Pull #1828)95* The `'wsgi.error'` configuration now defaults to `sys.stderr`, and is corrected to be a `TextIO` interface, not a `BytesIO` interface. Additionally, the WSGITransport now accepts a `wsgi_error` configuration. (Pull #1828)96* Follow the WSGI spec by properly closing the iterable returned by the application. (Pull #1830)9798## 0.19.0 (19th August, 2021)99
246 unmodified lines
346## 0.14.0 (August 7th, 2020)347348The 0.14 release includes a range of improvements to the public API, intended on preparing for our upcoming 1.0 release.349350* Our HTTP/2 support is now fully optional. **You now need to use `pip install httpx[http2]` if you want to include the HTTP/2 dependancies.**350* Our HTTP/2 support is now fully optional. **You now need to use `pip install httpx[http2]` if you want to include the HTTP/2 dependencies.**351* Our HSTS support has now been removed. Rewriting URLs from `http` to `https` if the host is on the HSTS list can be beneficial in avoiding roundtrips to incorrectly formed URLs, but on balance we've decided to remove this feature, on the principle of least surprise. Most programmatic clients do not include HSTS support, and for now we're opting to remove our support for it.352* Our exception hierarchy has been overhauled. Most users will want to stick with their existing `httpx.HTTPError` usage, but we've got a clearer overall structure now. See https://www.python-httpx.org/exceptions/ for more details.353354When upgrading you should be aware of the following public API changes. Note that deprecated usages will currently continue to function, but will issue warnings.
364 unmodified lines
719- Removed all private types from the top-level package export. (Pull #608)720- The SSL configuration settings of `verify`, `cert`, and `trust_env` now raise warnings if used per-request when using a Client instance. They should always be set on the Client instance itself. (Pull #597)721- Use plain strings "TUNNEL_ONLY" or "FORWARD_ONLY" on the HTTPProxy `proxy_mode` argument. The `HTTPProxyMode` enum still exists, but its usage will raise warnings. (#610)722- Pool timeouts are now on the timeout configuration, not the pool limits configuration. (Pull #563)723- The timeout configuration is now named `httpx.Timeout(...)`, not `httpx.TimeoutConfig(...)`. The old version currently remains as a synonym for backwards compatability. (Pull #591)723- The timeout configuration is now named `httpx.Timeout(...)`, not `httpx.TimeoutConfig(...)`. The old version currently remains as a synonym for backwards compatibility. (Pull #591)724725---726727## 0.8.0 (November 27, 2019)
120 unmodified lines
848- Add HSTS preload list checking within `BaseClient` to upgrade HTTP URLs to HTTPS. (Pull #184)849- Switch IDNA encoding from IDNA 2003 to IDNA 2008. (Pull #161)850- Expose base classes for alternate concurrency backends. (Pull #178)851- Improve Multipart parameter encoding. (Pull #167)852- Add the `headers` proeprty to `BaseClient`. (Pull #159)852- Add the `headers` property to `BaseClient`. (Pull #159)853- Add support for Google's `brotli` library. (Pull #156)854- Remove deprecated TLS versions (TLSv1 and TLSv1.1) from default `SSLConfig`. (Pull #155)855- Fix `URL.join(...)` to work similarly to RFC 3986 URL joining. (Pull #144)856
46 unmodified lines