Commit Graph

108 Commits

Author SHA1 Message Date
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
8c84210555
Increased test coverage & cleanup (#1003)
* Remove unused/untested headers copy() method

Last usage was removed in #804

* Remove unused premature_close server endpoint

Last usage was removed in #804

* Increased test coverage

* Revert removal of headers copy() method

Documented and added tests for it.

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-05-30 23:22:03 +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
Josep Cugat
093cb42500
Improve error when redirecting with custom schemes (#1002)
Fixes #822
2020-05-28 13:11:17 +02:00
Hasan Ramezani
21d7e16559
Fixed mypy errors in test_async_client.py and test_client.py (#985) 2020-05-27 21:29:52 +02:00
Tom Christie
7c8158a852
Add "Content-Length: 0" on POST, PUT, PATCH if required. (#995)
* Add Content-Length: 0 on POST, PUT, PATCH if required.

* Update tests/client/test_client.py

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

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-05-26 15:03:55 +01: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
d6b3794395
Attempt to resolve test flakiness (#946) 2020-05-12 16:02:25 +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
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
Evan Lurvey
707e54c484
Enable NO_PROXY environment variable support (#835)
* Enabling NO_PROXY env support

* Enabling NO_PROXY env var support and writing tests

* Update tests/client/test_proxies.py

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

* Update tests/client/test_proxies.py

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

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-03-02 16:51:34 +01:00
Florimond Manca
53804173bb
Drop backend parameter on AsyncClient (#791)
* Drop backend parameter on AsyncClient

* Fix master merge

Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-02-27 20:42:18 +00:00
Piotr Staroszczyk
efe9f61bc2
Drop RedirectLoop exception (#819)
* drop RedirectLoop exception

* tests is package to allow run it easly

* bring back test for redirect loop
2020-02-24 10:09:52 +00: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
1f8fb28d93
Handle redirect with malformed Location headers missing host. (#774) 2020-01-17 11:42:51 +00:00
Tom Christie
5a63540e8a
Fix for streaming a redirect response body with allow_redirects=False (#766) 2020-01-17 09:45:37 +00:00
Tom Christie
ee37a762ef
Reintroduce sync API. (#735)
* BaseClient and AsyncClient

* Introduce 'httpx.Client'

* Top level API -> sync

* Top level API -> sync

* Add WSGI support, drop deprecated imports

* Wire up timeouts to urllib3

* Wire up pool_limits

* Add urllib3 proxy support

* Pull #734 into sync Client

* Update AsyncClient docstring

* Simpler WSGI implementation

* Set body=None when no content

* Wrap urllib3 connection/read exceptions
2020-01-08 12:31:50 +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
f17ab37b2f
Prep for introducing SyncClient (#713)
* Reorganize method ordering in client

* Move 'request'

* Use 'httpx.Proxy' for proxy configuration
2020-01-07 10:27:01 +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
910aa9094c
Repurpose RedirectBodyUnavailable as RequestBodyUnavailable (#690) 2020-01-03 22:25:55 +01:00
Tom Christie
b0bf2a7513
SSLConfig refactor (#706)
* SSLConfig includes 'http2' argument on init.

* Pass SSL config to HTTPConnection as a single argument

* Don't run SSL context loading in threadpool
2020-01-02 10:54:04 +00:00
Tom Christie
b8394f1e00
Bump coverage (#705)
* Bump coverage

* Tests for iterative text decoding with 'aiter_text'

* nocover on xfail exception cases

* nocover API that is pending deprecation

* Tweak test to removed uncovered line

* Ingest request body in RedirectBodyUnavailable test case
2020-01-01 15:33:24 +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
Florimond Manca
3462999366 Rename 'next' to 'anext' on Response (#676)
* Rename 'next' to 'anext' on Response

* Drop iscoroutinefunction() check

Co-authored-by: Tom Christie <tom@tomchristie.com>
2019-12-29 15:34:07 +00:00
Florimond Manca
f9d18a8758 Rename 'read/close' to 'aread/aclose' on Response (#674)
* Switch to aread/aclose on responses

* Linting

Co-authored-by: Tom Christie <tom@tomchristie.com>
2019-12-29 15:14:53 +00:00
Florimond Manca
0ee0005154
Type-check test_cookies.py (#677) 2019-12-23 10:51:06 +01: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
Florimond Manca
d0427bead0
Clean up 'backend' fixture (#664)
* Clean up 'backend' fixture

* Add docstring to 'async_environment' fixture
2019-12-21 16:08:40 +01:00
Tom Christie
cee1fccaca
Use Streams API for both requests and responses. (#648)
* Internal ContentStreams API
2019-12-20 16:05:04 +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
6c69e0936b
No I/O auth (#644)
* No I/O on Auth
2019-12-18 15:25:31 +00:00
Tom Christie
8d4f182500
Added RequestContent (#636)
* Request Content

* Added RequestContent interface

* Docstrings on 'encode(data, files, json)'

* Update httpx/content.py

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

* can_rewind -> can_replay
2019-12-18 10:51:34 +00:00
Tom Christie
02d16bfb34 Trivial-case test for response.elapsed 2019-12-09 17:12:20 +00:00
Florimond Manca
ab41a5d5c3
Refactor tests in the light of backend auto-detection (#615)
* Refactor tests in the light of backend auto-detection

* Test passing explicit backend separately

* Drop 'backend=backend'

* Fix usage of asyncio.run() on 3.6
2019-12-07 15:17:35 +01:00
Tom Christie
ec40d04382
Add aiter methods on response (#610) 2019-12-06 15:20:09 +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
8d8ea8bbba
Add Client.stream() method. (#600)
* Add Client.stream() method.

* Add top-level stream API

* Documentation
2019-12-05 17:25:43 +00:00
Tom Christie
fc95c7e71e
stream -> stream_bytes, raw -> stream_raw (#599) 2019-12-05 11:39:28 +00:00
Tom Christie
eb7c6b0342
Differentiate between timeout=None and timeout=UNSET. (#592)
* TimeoutConfig -> Timeout

* Timeout=None should mean what it says.

* Drop optional timeout on internal client methods
2019-12-04 11:54:39 +00:00
Tom Christie
3cbe7315e8
Concurrency autodetection (#585)
* Simplify HTTP version config, and switch HTTP/2 off by default

* HTTP/2 docs

* HTTP/2 interlinking in docs

* Add concurrency auto-detection

* Add sniffio
2019-12-02 19:26:16 +00:00
Tom Christie
30229f1652
Better HTTP/2 defaults. (#584)
* Simplify HTTP version config, and switch HTTP/2 off by default

* HTTP/2 docs

* HTTP/2 interlinking in docs
2019-12-02 17:07:04 +00:00
Tom Christie
43331cfb3d Ensure Authorization header has priority over .netrc 2019-11-30 12:06:16 +00:00
Tom Christie
e045b86d7f
Clean up '_dispatcher_for_request' into 'dispatcher_for_url' (#561) 2019-11-29 11:21:40 +00:00
Tom Christie
206c5372a6
Drop sync (#544)
Drop sync client
2019-11-27 10:43:42 +00:00
Jonas Lundberg
7a96a2c896 Add support for unix domain sockets (#511)
* Add and implement open_uds_stream in concurrency backends

* Add uds arg to BaseClient and select tcp or uds in HttpConnection

* Make open stream methods in backends more explicit

* Close sentence

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

* Refactor uds concurrency test

* Remove redundant uds test assertions
2019-11-19 23:02:08 +01:00