Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push httpcore exception wrapping out of client into transport #1524

Merged
merged 3 commits into from
Mar 23, 2021

Conversation

tomchristie
Copy link
Member

@tomchristie tomchristie commented Mar 22, 2021

Follow-on to #1522

Transports should now raise httpx exception classes, rather than httpcore exception classes.

  • The httpcore -> httpx exception mapping now only occurs within the HTTPTransport() class, which uses the httpcore library.
  • The RequestError exceptions no longer require a request argument at the point of instantiation. The client class ensures that any RequestError raised by a transport will have a request attribute attached to it.
  • Transports now use plain byte iterables, with extensions['close']/extensions['aclose'] for any optional close callback.

Copy link
Member

@florimondmanca florimondmanca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isolation of exception mapping to the default transports is pretty neat. 👍

@tomchristie tomchristie merged commit ee2a612 into transport-api Mar 23, 2021
@tomchristie tomchristie deleted the tighten-httpcore-mapping branch March 23, 2021 10:05
tomchristie added a commit that referenced this pull request Mar 24, 2021
* Added httpx.BaseTransport and httpx.AsyncBaseTransport

* Test coverage and default transports to calling .close on __exit__

* BaseTransport documentation

* Use 'handle_request' for the transport API.

* Docs tweaks

* Docs tweaks

* Minor docstring tweak

* Transport API docs

* Drop 'Optional' on Transport API

* Docs tweaks

* Tweak CHANGELOG

* Drop erronous example.py

* Push httpcore exception wrapping out of client into transport (#1524)

* Push httpcore exception wrapping out of client into transport

* Include close/aclose extensions in docstring

* Comment about the request property on RequestError exceptions

* Extensions reason_phrase and http_version as bytes (#1526)

* Extensions reason_phrase and http_version as bytes

* Update BaseTransport docstring

* Neaten up our try...except structure for ensuring responses (#1525)

* Fix CHANGELOG typo

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>

* Fix CHANGELOG typo

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>

* stream: Iterator[bytes] -> stream: Iterable[bytes]

* Use proper bytestream interfaces when calling into httpcore

* Grungy typing workaround due to httpcore using Iterator instead of Iterable in bytestream types

* Update docs/advanced.md

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>

* Consistent typing imports across tranports

* Update docs/advanced.md

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants