Skip to content

Push httpcore exception wrapping out of client into transport - #1524

Merged
lovelydinosaur merged 3 commits into
transport-apifrom
tighten-httpcore-mapping
Mar 23, 2021
Merged

Push httpcore exception wrapping out of client into transport#1524
lovelydinosaur merged 3 commits into
transport-apifrom
tighten-httpcore-mapping

Conversation

@lovelydinosaur

@lovelydinosaurlovelydinosaur commented Mar 22, 2021

Copy link
Copy Markdown
Contributor

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.

@florimondmancaflorimondmanca left a comment

Copy link
Copy Markdown
Contributor

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. 👍

@lovelydinosaur
lovelydinosaur merged commit ee2a612 into transport-apiMar 23, 2021
@lovelydinosaur
lovelydinosaur deleted the tighten-httpcore-mapping branch March 23, 2021 10:05
lovelydinosaur 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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@lovelydinosaur@florimondmanca