Commit Graph

27 Commits

Author SHA1 Message Date
RafaelWO
7b19cd5f4b
Move utility functions from _utils.py to _client.py (#3389) 2024-11-15 11:42:52 +00:00
Polina Beskorovainaia
49d74a2e7f
Clarified error when header value is None (#3312)
Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-09-26 18:01:47 +01:00
Michiel W. Beijen
392dbe45f0
Add support for zstd decoding (#3139)
This adds support for zstd decoding using the python package zstandard.
This is similar to how it is implemented in urllib3. I also chose the
optional installation option httpx[zstd] to mimic the same option in
urllib3.

zstd decoding is similar to brotli, but in benchmarks it is supposed to
be even faster. The zstd compression is described in RFC 8878.

See https://github.com/encode/httpx/discussions/1986

Co-authored-by: Kamil Monicz <kamil@monicz.dev>
2024-03-21 10:17:15 +00:00
Adrian Garcia Badaracco
321d4aa509
Fix Headers.update to correctly handle repeated headers (#2038) 2022-01-21 08:35:10 -08:00
Tom Christie
9c7c2ace99
Add httpx.MockTransport() (#1401)
* Add httpx.MockTransport

* Add docs on MockTransport

* Add pointer to RESPX

* Add note on pytest-httpx

* Tweak existing docs example to use 'httpx.MockTransport'

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2021-01-06 11:04:26 +00: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
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
19b863af40
Header refinements (#1248)
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-09-02 21:32:48 +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
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
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
Florimond Manca
0296c2bbb9
Type check tests (#1054) 2020-07-07 11:10:43 +02:00
Taneli Hukkinen
6cf9039593
Improve list/dict comprehensions (#1036)
* Improve list/dict comprehensions

* Dont make needless list() conversions before bytes.join()

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-07-02 17:45:00 +02:00
Josep Cugat
89a8100b6c
Replace remaining occurrences of dispatch with transport (#1010)
* Replace remaining occurrences of dispatch with transport

* Remove unused AsyncDispatcher

Was removed in #804

* Remove hard_limit warning in test
2020-05-30 23:18:48 +02:00
Tom Christie
3046e920ea
Httpcore interface (#804)
* First pass as switching dispatchers over to httpcore interface

* Updates for httpcore interface

* headers in dispatch API as plain list of bytes

* Integrate against httpcore 0.6

* Integrate against httpcore interface

* Drop UDS, since not supported by httpcore

* Fix base class for mock dispatchers in tests

* Merge master and mark as potential '0.13.dev0' release
2020-04-08 13:32:10 +01:00
Tom Christie
631ba97635
Revert "Add content-length header for empty bytestream (#866)" (#898)
This reverts commit 939f3ce7ce.
2020-04-08 13:15:22 +01:00
Dima Boger
939f3ce7ce
Add content-length header for empty bytestream (#866)
Also, fixed related tests
2020-03-28 16:05:06 +01:00
Florimond Manca
82dc6f32f8 Switch to private module names (#785)
* Rename modules

* Update names in package

* Fix tests

* Review docs
2020-01-28 14:34:43 +00:00
Tom Christie
e19bd9bc4b
Dispatcher -> AsyncDispatcher (#725)
* Dispatcher -> AsyncDispatcher

* Fix invalid renamings

* Fix invalid renamings
2020-01-06 12:08:14 +00:00
Florimond Manca
e284b84bf9 Rename Client to AsyncClient (with compat synonym) (#680)
* Rename Client to AsyncClient (with compat synonym)

* Document motivation for AsyncClient renaming

Co-authored-by: Tom Christie <tom@tomchristie.com>
2019-12-29 15:34:23 +00:00
Tom Christie
5ee512d803
Fix Host header and HSTS when the default port is explicitly included in URL (#649) 2019-12-20 10:25:42 +00:00
Tom Christie
d15dc0b1f8
Tighten up top-level API to only expose public API (#608)
* Tighten up top-level API to only expose public API

* Leave HTTPProxyMode for backwards compat, raising warnings.

* Add missing import
2019-12-06 15:20:01 +00:00
Tom Christie
206c5372a6
Drop sync (#544)
Drop sync client
2019-11-27 10:43:42 +00:00
Can Sarıgöl
dd3fbcc8d7 Don't include username/password components in Host header (#417)
* removed auth and port from host of header

* used URL attribute rather _uri_reference

* reverted removing port into host

* reverted username and password from header

* applied new copy_with with username and password
2019-10-04 10:33:18 +01:00
Gaurav Dhameeja
0f34f3b60f Raise KeyError if header isn't found in Headers (#324) 2019-09-07 16:12:37 -05:00
Yeray Diaz Diaz
95dad247b5 Remove "Host" header on redirects if URL origin has changed (#199)
Fixes #198

* Reinstate accidentally removed return statement
2019-08-13 06:44:23 -05:00
Stephen Brown II
72e6f47897 Allow setting headers at the Client level (#159) 2019-07-28 20:39:35 -05:00