Commit Graph

410 Commits

Author SHA1 Message Date
Musale Martin
815ef94ed9
Support header comparisons with dict or list. (#1326)
* Support header comparisons with dict or list.

* Add check for no headers item

* Fixup testcases affected by headers comparison using dict or list

* Update test_responses.py

Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-09-25 12:28:34 +01:00
Tom Christie
666cbbdfe8
Fix automatic .read() when Response instances are created with content=<str> (#1324) 2020-09-25 11:29:17 +01:00
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
e53f995994
Fix ASGITransport path escaping (#1307) 2020-09-23 09:37:19 +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
8e4a8a1c73
Finesse URL properties (#1285)
* url.userinfo should be URL encoded bytes

* Neater copy_with implementation

* Finesse API around URL properties and copy_with

* Docstring for URL, and drop url.authority

* Support url.copy_with(raw_path=...)

* Docstrings on URL methods

* Tweak docstring
2020-09-21 11:35:25 +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
354c4cac1f
Refactor content streams (#1296)
* Refactor content_streams internally

* Tidy up multipart

* Use ByteStream annotation internally
2020-09-18 10:50:15 +01:00
Tom Christie
fbb21fb1ae
Drop ContentStream (#1295)
* Drop ContentStream
2020-09-18 08:41:09 +01:00
Tom Christie
e1f7791e97
Requests from transport API (#1293)
* Refactoring to support instantiating requests from transport API

* Minor refactoring
2020-09-17 11:59:42 +01:00
Tom Christie
09f94edd93
encode -> encode_request (#1292) 2020-09-17 09:33:36 +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
5ee6135256
Support Response(content=<bytes iterator>) (#1265)
* Support Response(content=<bytes iterator>)

* Update test for merged master
2020-09-11 10:28:18 +01:00
cdeler
ed16eb3a3d
Add progress to streaming download (#1268)
* Added last_raw_chunk_size to the Response object (#1208)

* Added example with progress bar (#1208)

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

* Apply suggestions from code review

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

* PR review
Changed last_raw_chunk_size to num_bytes_downloaded ;
Edited the example according to documentaion

* Update docs/advanced.md

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

* Update docs/advanced.md

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

* Update docs/advanced.md

* Update docs/advanced.md

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-09-10 12:16:00 +03: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
cdeler
15187e7c21
Fixed test_multiple_set_cookie (#1270)
* Fixed test_multiple_set_cookie

* Update test_cookies.py

Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-09-09 10:01:39 +01:00
Tom Christie
a783fe5758
Drop request.timer attribute. (#1249)
* Drop request.timer attribute
* Response(..., elapsed_func=...)
2020-09-07 09:06:14 +01:00
Tyler Wozniak
42c66863d0
Raise a proper type error on invalid URL type (#1259)
* Added test for expected URL class behavior

* Updated URL class, tests pass

* Updated to include type in error message
2020-09-04 23:14:59 +02: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
de502a44c6
Drop Response(..., request=...) style in test cases. (#1243)
* Drop Response(..., request=...) style in test cases except where required

* Lowercase variable name
2020-09-02 10:10:32 +01:00
Tom Christie
e39a6d9ef4
Use sync client in test cases (#1241)
* Use sync client in test cases

* Use plain client __init__ style in preference to context manager

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-09-01 22:44:52 +02:00
Tom Christie
cf5970336a
Minor test refactoring (#1242) 2020-09-01 22:41:30 +02:00
tbascoul
e0b4528b17
Make the response's request parameter optional (#1238)
* Make the response's request parameter optional

* Fix _models coverage

* Move DecodingError in _models

* Update httpx/_models.py

* Update _models.py

* Update test_responses.py

* Update test_responses.py

Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-09-01 15:14:57 +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
cdeler
6e6ece66c6
Made cookies construct-able from a list of tuples (#1211)
* Added test which checks that cookie might be built from a list of tuples (#1209)

* Made cookies constructable from a list of tuples (#1209)
2020-08-24 10:44:48 +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
Joe
03cd88c336
Map httpcore exceptions for Response read methods (#1190)
* Map httpcore exceptions for `Response.iter_*` methods

* Tweak

* Change wording

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

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-08-19 12:10:04 +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
Josep Cugat
842ccfafe6
Add exported members test (#1179)
Taken from https://github.com/encode/httpcore/pull/156
Added as a followup of https://github.com/encode/httpx/pull/1177#issuecomment-674252582
2020-08-15 12:24:26 +02:00
Tom Christie
655773e1c1
Handle URL quoting username and password components. (#1159)
* Handle URL quoting username and password components

* Tweak userinfo quoting
2020-08-11 17:18:12 +01:00
Joe
5b6d33e29c
Ignore transfer-encoding if content-length presents (#1170)
* Ignore transfer-encoding if content-length presents

Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-08-11 23:43:57 +08: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
4cf74bc405
Fix behaviour with multiple Set-Cookie headers (#1156) 2020-08-10 14:53:51 +01:00
Tom Christie
8c7729e42c
Version 0.14.0 (#1083)
* Version 0.14.0

* Update CHANGELOG

* Update CHANGELOG.md

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

* Update CHANGELOG

* max_keepalive_connections

* Add deprecation test

* Update CHANGELOG.md

* Undate dependency pin callout

* Update expected 1.0 release date

Co-authored-by: Stephen Brown II <Stephen.Brown2@gmail.com>
2020-08-07 15:50:25 +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