Skip to content

Commit

Permalink
Supplement the current requests-based HTTP backend by a new one based…
Browse files Browse the repository at this point in the history
… 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%!
  • Loading branch information
ntninja committed Jun 26, 2020
1 parent d8de31a commit d5da242
Show file tree
Hide file tree
Showing 14 changed files with 1,449 additions and 638 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ matrix:
- python: "pypy3"
- python: "3.8"
env: IPFS_VERSION=compat
- python: "3.8"
env: TOXENV=py3-httpx
- python: "3.8"
env: TOXENV=styleck
before_install: ":"
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Other changes:
* The new *period_special* parameter allows toggling whether glob patterns match dot-files implicietly and defaults to `True` (previously it was effectively `False`)
* 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)
* `.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
* 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.

py-ipfs-http-client 0.4.12 (21.05.2019)
---------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions ipfshttpclient/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ def ident(value: T) -> T:

class ResponseWrapIterator(ty.Generic[T, R]):
__slots__ = ("_inner", "_item_wrap_cb")
#_inner: http.StreamDecodeIterator
#_inner: http.StreamDecodeIteratorSync
#_item_wrap_cb: wrap_cb_t

def __init__(self, inner: http.StreamDecodeIterator, item_wrap_cb: wrap_cb_t):
def __init__(self, inner: http.StreamDecodeIteratorSync, item_wrap_cb: wrap_cb_t):
self._inner = inner
self._item_wrap_cb = item_wrap_cb

Expand Down Expand Up @@ -277,7 +277,7 @@ def __init__(
if auth is None and (username or password):
auth = (username, password)

self._client = http.HTTPClient(
self._client = http.ClientSync(
addr, base, offline=offline,
auth=auth, cookies=cookies, headers=headers, timeout=timeout,
)
Expand Down
Loading

0 comments on commit d5da242

Please sign in to comment.