Commit Graph

160 Commits

Author SHA1 Message Date
Tom Christie
320bfe1d0e
Fix warning test case (#1322) 2020-09-24 18:50:30 +02:00
Tom Christie
d25f2bfeff
Fix stream unsetting auth (#1312)
* Fix ASGITransport path escaping

* Add failing test case for auth with streaming

* Fix .stream setting auth=None
2020-09-23 11:25:54 +01:00
Tom Christie
f932af9172
Version 0.15.0 (#1301)
* Version 0.15.0

* Update CHANGELOG.md

Co-authored-by: Jamie Hewland <jamie.hewland@hpe.com>

* Escalate deprecations into removals.

* Deprecate overly verbose timeout parameter names

* Fully deprecate max_keepalive in favour of explicit max_keepalive_connections

* Fully deprecate PoolLimits in favour of Limits

* Deprecate instantiating 'Timeout' without fully explicit values

* Include deprecation notes in changelog

* Use httpcore 0.11.x

Co-authored-by: Jamie Hewland <jamie.hewland@hpe.com>
2020-09-22 11:44:28 +01:00
Tom Christie
f3c29416f1
Support Response(text=...), Response(html=...), Response(json=...) (#1297)
* Refactor content_streams internally

* Tidy up multipart

* Use ByteStream annotation internally

* Support Response(text=...), Response(html=...), Response(json=...)

* Add tests for Response(text=..., html=..., json=...)
2020-09-21 11:19:19 +01:00
Tom Christie
fbb21fb1ae
Drop ContentStream (#1295)
* Drop ContentStream
2020-09-18 08:41:09 +01:00
Tom Christie
feb404f86b
Seperate content=... and data=... parameters (#1266)
* Seperate content=... and data=... parameters

* Update compatibility.md
2020-09-15 13:36:10 +01:00
Tom Christie
54f7708e2b
Event hooks (#1246)
* Add EventHooks internal datastructure

* Add support for 'request' and 'response' event hooks

* Support Client.event_hooks property

* Handle exceptions raised by response event hooks

* Docs for event hooks

* Only support 'request' and 'response' event hooks

* Add event_hooks to top-level API

* Event hooks

* Formatting

* Formatting

* Fix up event hooks test

* Add test case to confirm that redirects/event hooks don't currently play together correctly

* Refactor test cases

* Make response.request clear in response event hooks docs

* Drop merge marker

* Request event hook runs as soon as we have an auth-constructed request
2020-09-15 12:05:39 +01:00
Tom Christie
d0fe113945
Drop chardet (#1269)
* Internal refactoring to swap auth/redirects ordering

* Drop chardet for charset detection

* Drop chardet in favour of simpler charset autodetection

* Revert unintentionally included changes

* Update test case

* Refactor to prefer different decoding style

* Update text decoding docs/docstrings

* Resolve typo

* Update docs/quickstart.md

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

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-09-15 11:20:19 +01:00
Tom Christie
2d6c30d061
Refactor test_auth.py to use MockTransport class. (#1288)
* Use tests.utils.MockTransport

* Use tests.utils.MockTransport
2020-09-14 17:44:05 +01:00
Tom Christie
c2afd2d9bf
Refactor tests to use MockTransport(<handler_function>) (#1281)
* Support Response(content=<bytes iterator>)

* Update test for merged master

* Add MockTransport for test cases

* Use MockTransport for redirect tests

* Reduce change footprint

* Reduce change footprint

* Clean up headers slightly

* Update requirements.txt

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-09-12 11:16:10 +01:00
Tom Christie
4d950e5780
Swap auth/redirects ordering (#1267)
* Internal refactoring to swap auth/redirects ordering

* Test for auth with cross domain redirect
2020-09-10 09:12:05 +01:00
Florimond Manca
016e4ee210
Add support for sync-specific or async-specific auth flows (#1217)
* Add support for async auth flows

* Move body logic to Auth, add sync_auth_flow, add NoAuth

* Update tests

* Stick to next() / __anext__()

* Fix undefined name errors

* Add docs

* Add unit tests for auth classes

Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-09-09 14:37:20 +01:00
Tom Christie
19b863af40
Header refinements (#1248)
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-09-02 21:32:48 +01:00
cdeler
def9f1c320
Issue warning on unclosed AsyncClient. (#1197)
* Made Client and AsyncClient checking for being closed in __del__ (#871)

* Changed the AsyncClient closing warning type from ResourceWarning (which is too quiet) to UserWarning  (#871)

* Fixed tests and client's __exit__ and __aexit__ after the difficult merge (#871)

* Update test_proxies.py

* Update test_proxies.py

Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-09-02 13:02:59 +01:00
Tom Christie
33d339a262
Handle multiple auth headers correctly (#1240)
Handle multiple auth headers correctly
2020-09-01 14:08:10 +01:00
cdeler
fa7661b306
Closing AsyncClient in all tests (#871) (#1219)
All over the AsyncClient invocation is made using context manager or with try-finally block
2020-08-31 18:02:28 +03:00
Eduardo Enriquez
aad8209928
Replace httpx.URL for str in tests (#1237)
Co-authored-by: Eduardo Enriquez (eduzen) <eduardo.enriquez@freshbooks.com>
2020-08-30 08:01:37 +02:00
Florimond Manca
f5c27ec7f4
Use and pin black 20 (#1229) 2020-08-27 14:57:53 +01:00
Tom Christie
28c72050e0
Better test case consistency. Prefer import httpx and httpx.Client. (#1222)
* Prefer httpx.Client over httpx.AsyncClient in test cases, unless required.

* Prefer httpx.Client in test_headers

* Consistent httpx imports and httpx.Client usage

* Use 'import httpx' consistently in tests. Prefer httpx.Client.
2020-08-26 14:10:23 +01:00
Tom Christie
534400ee42
Context managed transports (#1218)
* Context managed transports

* Update httpx/_client.py

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

* Update httpx/_client.py

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

* Update tests/client/test_client.py

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

* Update tests/client/test_async_client.py

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

* Code comment around close/__enter__/__exit__ interaction

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-08-26 12:05:05 +01:00
Tom Christie
19515e8a8b
Fix request auto headers (#1205)
* Failing test case

* Fix auto_headers in Request.prepare()

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-08-21 12:03:15 +01:00
Florimond Manca
cb620e67c7
Add Client.auth setter (#1185) 2020-08-17 14:51:52 +02:00
Florimond Manca
09c3e90e3b
Add test for HEAD redirect behavior (#1184) 2020-08-16 08:12:17 +02:00
Florimond Manca
a4463d044f
Allow disabling auth per-request using auth=None (#1115)
Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-08-11 15:18:27 +02:00
Joe
45de714592
Map rfc3986 exceptions (#1163)
* Map rfc3896 exceptions
2020-08-11 09:44:56 +01:00
Tom Christie
8d9dfb54fc
HTTP/2 becomes fully optional (#1140)
* HTTP/2 becomes fully optional

* Fix linting, coverage
2020-08-07 15:16:21 +01:00
Tom Christie
876e722b24
Update to httpcore 0.10 (#1126)
* Keep HTTPError as a base class for .request() and .raise_for_status()

* Updates for httpcore 0.10

* Update httpx/_exceptions.py

Co-authored-by: Stephen Brown II <Stephen.Brown2@gmail.com>

* Use httpcore.SimpleByteStream/httpcore.IteratorByteStream

* Use httpcore.PlainByteStream

* Merge master

* Update to httpcore 0.10.x

Co-authored-by: Stephen Brown II <Stephen.Brown2@gmail.com>
2020-08-07 14:14:11 +01:00
cdeler
7123b0f7ba
#1066 make BaseClient's timeout accessible using getters and setters (#1135) 2020-08-06 12:09:21 +01:00
Tom Christie
0e73be83a8
Deprecate URL.is_ssl (#1128) 2020-08-05 19:10:59 +01:00
Tom Christie
a3392c6ea7
Base URL improvements (#1130)
* URL.join(url=...), not URL.join(relative_url=...)

* Fix URL.join()

* Support no argument 'httpx.URL()' usage

* Support client.base_url as a property

* Resolve base_url joining behaviour

* Fix coverage

* Update _client.py
2020-08-05 18:56:25 +01:00
cdeler
7279ed4658
Raise warning if proxy key is eg. "all" instead of "all://". (#1127)
* #1105 added deprecation warning, raised when we try to use proxies={"http": ...} instead of {"http://": ...}. Updated docs and added unit, which check the warning presence

* Update tests/client/test_proxies.py

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

* Update tests/client/test_proxies.py

Co-authored-by: Tom Christie <tom@tomchristie.com>
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-08-05 18:41:50 +01:00
Florimond Manca
78cf16ace9
Drop HSTS Preloading (#1110)
* Drop HSTS Preloading

* Update test_client.py

Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-08-05 13:05:45 +01:00
Joe
d76b2c2fb7
Handle bare env proxy hostname gracefully (#1120) 2020-08-02 10:48:09 +01:00
Tom Christie
682cad39eb
Cleaner no proxy support (#1103)
* Add internal URLMatcher class

* Use URLMatcher for proxy lookups in transport_for_url

* Docstring

* Pin pytest

* Add support for no-proxies configurations

* Don't call should_not_proxy on each request

* Drop print statements

* Tweak comment

* Tweak comment on domain wildcards

* Update httpx/_utils.py

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

* Pull test_should_not_be_proxied cases into test_proxies_environ

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-08-02 10:00:45 +01:00
Florimond Manca
f67e925f72
Rename PoolLimits to Limits (#1113)
* Rename PoolLimits to Limits

* Lint

Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-08-01 20:44:58 +01:00
Florimond Manca
71d5234305
Rename URLMatcher -> URLPattern (#1109) 2020-08-01 11:07:31 +02:00
Tom Christie
9409900898
Exception hierarchy (#1095)
* Exception heirachy

* Exception heirarchy

* Formatting tweaks

* Update httpx/_exceptions.py

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

* Update httpx/_exceptions.py

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

* Update httpx/_exceptions.py

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

* Update httpx/_exceptions.py

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

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-07-31 12:57:49 +01:00
Tom Christie
16893e414f
Add support for no-proxy configurations (#1099)
* Add internal URLMatcher class

* Use URLMatcher for proxy lookups in transport_for_url

* Docstring

* Pin pytest

* Add support for no-proxies configurations
2020-07-31 10:21:11 +01:00
Tom Christie
df54890c15
URL matching (#1098)
* Add internal URLMatcher class

* Use URLMatcher for proxy lookups in transport_for_url

* Docstring

* Pin pytest

* Update httpx/_utils.py

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

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-07-31 10:11:49 +01:00
Tom Christie
2d491c9e7d
Full coverage, with exception of URLLib3Transport (#1086) 2020-07-24 15:24:06 +01:00
Tom Christie
c089480260
URL.port becomes Optional[int] (#1080)
* URL.port becomes Optional[int], not int

* Minor _transport_for_url refactor

* Add docstring
2020-07-24 11:42:13 +01:00
Tom Christie
696c1eff03
Parameterize invalid URL tests (#1079) 2020-07-23 10:40:00 +01:00
Tom Christie
7e6e35160f
Drop URL(allow_relative=bool) (#1073)
* Drop URL(allow_relative=bool)

* Update httpx/_models.py

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

* Linting

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-07-23 10:16:51 +01:00
François Voron
0641606619
Skip HSTS preloading on single-label domains (#1074)
Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-07-21 10:40:10 +01:00
François Voron
27b0dbc22d
Raise HTTPStatusError in raise_from_status (#1072) 2020-07-20 13:10:57 +01:00
Tom Christie
a89d4ad625
More public API tightening (#1065) 2020-07-17 11:19:24 +01:00
Tom Christie
e107e0f842
Tighten public client methods (#997)
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-07-17 10:20:52 +01:00
Florimond Manca
09672a99dd
Use relative tests directory references (#1052)
* Use relative tests directory references

* Use absolute TESTS_DIR

Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-07-16 16:28:31 +02:00
Tom Christie
3f96e74961
Drop deprecated API (#1057)
* Drop ASGIDispatch, WSGIDispatch, which has been replaced by ASGITransport, WSGITransport.
* Drop dispatch=... on client, which has been replaced by transport=...
* Drop soft_limit, hard_limit, which have been replaced by max_keepalive and max_connections.
* Drop Response.stream and Response.raw, which have been replaced by aiter_bytes and aiter_raw.
* Drop internal usage of as_network_error in favour of map_exceptions.
2020-07-15 12:19:56 +01:00
Florimond Manca
0296c2bbb9
Type check tests (#1054) 2020-07-07 11:10:43 +02:00