Skip to content

Commit d5da242

Browse files
committed
Supplement the current requests-based HTTP backend by a new one based on HTTPx
From the changelog: * The requests-based HTTP backend has been supplemented by another backend based on [HTTPx](https://www.python-httpx.org/) for Python 3.6+ * Due to a minor limitation within the library (no ability to apply address family restrictions during name resolution) this currently included as a preview and must be manually enabled, to do this ensure that the `httpx` library is installed in your Python environment and run your program with the environment variable *PY_IPFS_HTTP_CLIENT_PREFER_HTTPX* set to *yes*. * In the hopefully not too long future, HTTPx will be used to finally provide async/await support for this library. Additionally this brings of `http*.py` things to 100% and total coverage to ~92%!
1 parent d8de31a commit d5da242

File tree

14 files changed

+1449
-638
lines changed

14 files changed

+1449
-638
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ matrix:
1212
- python: "pypy3"
1313
- python: "3.8"
1414
env: IPFS_VERSION=compat
15+
- python: "3.8"
16+
env: TOXENV=py3-httpx
1517
- python: "3.8"
1618
env: TOXENV=styleck
1719
before_install: ":"

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Other changes:
1818
* The new *period_special* parameter allows toggling whether glob patterns match dot-files implicietly and defaults to `True` (previously it was effectively `False`)
1919
* The new *follow_symlinks* parameter similarily determines whether symbolic links will be followed when scanning directory trees and defaults to `False` (the previous default on Unix, albeit this likely wasn't intentional)
2020
* `.add()` will now limit its scan to the directories required to match the given glob patterns (passing in regular expression objects will still scan the tree unconditionally however) – custom matchers have full control over which directories are visited
21+
* The requests-based HTTP backend has been supplemented by another backend based on [HTTPx](https://www.python-httpx.org/) for Python 3.6+
22+
* Due to a minor limitation within the library (no ability to apply address family restrictions during name resolution) this currently included as a preview and must be manually enabled, to do this ensure that the `httpx` library is installed in your Python environment and run your program with the environment variable *PY_IPFS_HTTP_CLIENT_PREFER_HTTPX* set to *yes*.
23+
* In the hopefully not too long future, HTTPx will be used to finally provide async/await support for this library.
2124

2225
py-ipfs-http-client 0.4.12 (21.05.2019)
2326
---------------------------------------

ipfshttpclient/client/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ def ident(value: T) -> T:
8686

8787
class ResponseWrapIterator(ty.Generic[T, R]):
8888
__slots__ = ("_inner", "_item_wrap_cb")
89-
#_inner: http.StreamDecodeIterator
89+
#_inner: http.StreamDecodeIteratorSync
9090
#_item_wrap_cb: wrap_cb_t
9191

92-
def __init__(self, inner: http.StreamDecodeIterator, item_wrap_cb: wrap_cb_t):
92+
def __init__(self, inner: http.StreamDecodeIteratorSync, item_wrap_cb: wrap_cb_t):
9393
self._inner = inner
9494
self._item_wrap_cb = item_wrap_cb
9595

@@ -277,7 +277,7 @@ def __init__(
277277
if auth is None and (username or password):
278278
auth = (username, password)
279279

280-
self._client = http.HTTPClient(
280+
self._client = http.ClientSync(
281281
addr, base, offline=offline,
282282
auth=auth, cookies=cookies, headers=headers, timeout=timeout,
283283
)

0 commit comments

Comments
 (0)