Commit Graph

62 Commits

Author SHA1 Message Date
Tom Christie
eeb5e3c2a3
Cleanup unneccessary test case (#3375) 2024-10-28 17:38:33 +00:00
BERRADA-Omar
9fd6f0ca66
Ensure JSON representation is compact. #3363 (#3367)
Co-authored-by: Tom Christie <tom@tomchristie.com>
2024-10-28 14:40:22 +00:00
T-256
0006ed0547
format (#3131)
Co-authored-by: T-256 <Tester@test.com>
2024-03-01 19:49:23 +00:00
T-256
fd60b1815c
Ruff linter: Use the default line-length (#2922)
Co-authored-by: Tester <Tester@test.com>
Co-authored-by: Kar Petrosyan <92274156+karpetrosyan@users.noreply.github.com>
2023-11-29 13:28:31 +04:00
Petr Belskiy
87f39f12c9
add missing type hints to __init__(...) (#2938)
* add missing type hints to __init__

https://peps.python.org/pep-0484/

* add info to changelog

* Update CHANGELOG.md

* Update CHANGELOG.md

---------

Co-authored-by: Kar Petrosyan <92274156+karpetrosyan@users.noreply.github.com>
Co-authored-by: Tom Christie <tom@tomchristie.com>
2023-11-17 17:58:51 +04:00
Adrian Garcia Badaracco
f0fd91925b
fix type annotation for MockTransport (#2581)
* fix type annotation for MockTransport

* add type ignore

* better type checks

* better type checks

* add pragma

---------

Co-authored-by: Tom Christie <tom@tomchristie.com>
2023-02-09 16:05:07 +00:00
Tom Christie
59914c7690
Add NetRCAuth() class. (#2535)
* NetRCAuth class

* Add docs for httpx.NetRCAuth()

* Drop failing cross-domain test for NetRCAuth()

* Update tests

* Update httpx/_auth.py

* Add tests for netrc file with no password
2023-01-12 11:27:46 +00:00
Thomas Grainger
e27d1b8333
replace pytest-asyncio and pytest-trio with anyio (#2512)
* replace pytest-asyncio with anyio

* remove pytest-trio also

* Update setup.cfg

* use anyio.Lock in test_auth

Co-authored-by: Tom Christie <tom@tomchristie.com>
2023-01-02 12:53:30 +00:00
Tom Christie
7985f685ca
Use consistent import style (#2493) 2022-12-06 11:58:30 +00:00
Martijn Pieters
933551c519
Typing: enable disallow_untyped_calls (#2479)
* Typing: enable disallow_untyped_calls

Only the test suite needed adjusting to add type hints.

* Update setup.cfg

Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-12-02 10:47:42 +00:00
rettier
8327e13454
reuse the digest auth state to avoid unnecessary requests (#2463)
* reuse the digest auth challenge to avoid sending twice as many requests

* fix for digest testcase

* ran testing/linting scripts

* codereview changes, removed tomchristie username from all authentication tests

Co-authored-by: Philipp Reitter <p.reitter@accessio.at>
Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-11-29 17:05:37 +00:00
Adrian Garcia Badaracco
1b4e7fbb48
Typing: always fill in generic type parameters (#2468)
* Typing: always fill in generic type parameters

Being explicit about the parameters helps find bugs and makes the library
easier to use for users.

- Tell mypy to disallow generics without parameter values
- Give all generic types parameters values

* fix things that aren't coming in from other commits

* lint

Co-authored-by: Martijn Pieters <mj@zopatista.com>
Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-11-29 16:36:03 +00:00
Adrian Garcia Badaracco
16e2830624
use # pragma: no cover instead of # pragma: nocover (#2471)
Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-11-29 10:23:18 -06:00
Tom Christie
ff9813e84d
Transport API as plain request -> response method. (#1840)
* Responses as context managers

* timeout -> request.extensions

* Transport API -> request/response signature

* Fix top-level httpx.stream()

* Drop response context manager methods

* Simplify ASGI tests

* Black formatting
2021-09-13 13:34:46 +01:00
Tom Christie
397aad98fd
Escalate the distinction between data=... and content=... to be stricter (#1573) 2021-04-16 10:06:12 +01: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
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
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
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
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
Florimond Manca
f5c27ec7f4
Use and pin black 20 (#1229) 2020-08-27 14:57:53 +01:00
Florimond Manca
cb620e67c7
Add Client.auth setter (#1185) 2020-08-17 14:51:52 +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
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
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
Florimond Manca
0296c2bbb9
Type check tests (#1054) 2020-07-07 11:10:43 +02:00
Josep Cugat
620b0670db
Increase test coverage - take 2 (#1012)
* Fix HttpError -> HTTPError typo

* Increased test coverage

* Increase coverage threshold

* Reuse sync/async transport code in test_auth.py

* Removed close_client check inside StreamContextManager

It's never set as True when used in async

* Reuse sync/async transport code in test_redirects.py
2020-06-02 10:24:45 +01: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
Yeray Diaz Diaz
d2816c9c48
Transport API (#963)
* Deprecate Client arg 'dispatch' and use 'transport'

* Remove line in test from coverage

* Document custom transports

* _dispatch > _transports

Also rename *Dispatch classes to *Transport and added aliases

* Fix linting issues

* Missed one _transports import

* Promote URLLib3Transport to public API

* Remove duplicate arg doc

* Assert that urllib3 is imported to use URLLib3Transport

* `AsyncClient`, not asynchronous `Client`

* Add warning category to warn calls

* Update docs/advanced.md

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

* Add warn_deprecated utility function

* Amend docs references to dispatch

* Add concrete implementation example

* Clearer transport implementation description

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-05-21 12:22:17 +01: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
George Kettleborough
b3db9ff0b6
Add Auth.requires_response_body attribute (#803)
* Add Auth.requires_response_body attribute

If set then responses are read by the client before being sent back into the auth flow

* Update tests and docs

* PR fixes

* Change example methods
2020-02-10 12:10:11 +00: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
12dd157fea
Public Auth API (#732)
* Public Auth API

* Minor docs tweak

* Request.aread and Request.content

* Support requires_request_body

* Update tests/models/test_requests.py

Co-Authored-By: Florimond Manca <florimond.manca@gmail.com>

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-01-07 13:20:23 +00:00
Tom Christie
e19bd9bc4b
Dispatcher -> AsyncDispatcher (#725)
* Dispatcher -> AsyncDispatcher

* Fix invalid renamings

* Fix invalid renamings
2020-01-06 12:08:14 +00:00
Kousik Mitra
0ed0314569 Raise an exception in DigestAuth if non-replayable request is passed (#685)
* DigestAuth will raise exception if non-replayble request is passed #670

* Added new exception RequestBodyUnavailble exception to raise non replayable request error #670

* Changed RedirectBodyUnavailable exception to RequestBodyUnavailble to raise non-replayable exception #670

* fixed class declaration

* Added RequestBodyUnavailable exception. Imported it in module level

* Added RequestBodyUnavailable in the module list

* Code reformat

* Added Test to check if exception is raising if non-replayble request body is passed to DigestAuth #670
2020-01-04 10:00:34 +01:00
Florimond Manca
bc6163c55a
Record history of requests made during authentication (#718)
* Record history of requests made during authentication

* Add asserts on digest auth history

Co-Authored-By: Gaurav Dhameeja <gdhameeja@gmail.com>
2020-01-03 22:59:16 +01: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
Florimond Manca
49e4d155ee
Type-check test_auth.py (#665)
* Type-check test_auth.py

* Drop request cast
2019-12-21 18:48:55 +01:00
Tom Christie
6c69e0936b
No I/O auth (#644)
* No I/O on Auth
2019-12-18 15:25:31 +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
43331cfb3d Ensure Authorization header has priority over .netrc 2019-11-30 12:06:16 +00:00
Tom Christie
206c5372a6
Drop sync (#544)
Drop sync client
2019-11-27 10:43:42 +00:00
Seth Michael Larson
05f5dc26de
Get test suite back to ~100% line coverage (#406) 2019-09-29 13:58:22 -05:00
Yeray Diaz Diaz
1cd9156d5d Additional DigestAuth tests (#334) 2019-09-11 07:25:11 -05:00
Yeray Diaz Diaz
fd3b69d2aa Add DigestAuth middleware (#332)
* Remove global variable, just return response from auth request

* Add extra space to Digest header start assertion

* Prevent unpacking errors limiting the number of splits
2019-09-10 14:53:39 -05:00