Commit Graph

587 Commits

Author SHA1 Message Date
Tom Christie
110ce85652
Stream interface (#1550)
* Add SyncByteStream, AsyncByteStream to interface

* request.stream and response.stream as httpx.SyncByteStream/httpx.AsyncByteStream

* Update httpx/_transports/base.py

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

* Update httpx/_transports/default.py

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

* Move response classes in transports to module level

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2021-04-13 13:14:04 +01:00
Jonas Lundberg
52dd95fb5c
Fix extenstions typo in AsyncHTTPTransport (#1549) 2021-04-01 15:32:20 +01:00
Tom Christie
c26425aa58
Handle data={"key": [None|int|float|bool]} cases. (#1539)
* Fix Content-Length for unicode file contents with multipart

* Handle bool and None cases for URLEncoded data

* Handle int, float, bool, and None for multipart or urlencoded data

* Update httpx/_utils.py

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

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2021-03-26 12:54:04 +00:00
Tom Christie
c75ddc26c7
Fix Content-Length for unicode file contents with multipart (#1537) 2021-03-25 15:35:02 +00:00
Tom Christie
1a6e254f72
Transport API (#1522)
* Added httpx.BaseTransport and httpx.AsyncBaseTransport

* Test coverage and default transports to calling .close on __exit__

* BaseTransport documentation

* Use 'handle_request' for the transport API.

* Docs tweaks

* Docs tweaks

* Minor docstring tweak

* Transport API docs

* Drop 'Optional' on Transport API

* Docs tweaks

* Tweak CHANGELOG

* Drop erronous example.py

* Push httpcore exception wrapping out of client into transport (#1524)

* Push httpcore exception wrapping out of client into transport

* Include close/aclose extensions in docstring

* Comment about the request property on RequestError exceptions

* Extensions reason_phrase and http_version as bytes (#1526)

* Extensions reason_phrase and http_version as bytes

* Update BaseTransport docstring

* Neaten up our try...except structure for ensuring responses (#1525)

* Fix CHANGELOG typo

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

* Fix CHANGELOG typo

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

* stream: Iterator[bytes] -> stream: Iterable[bytes]

* Use proper bytestream interfaces when calling into httpcore

* Grungy typing workaround due to httpcore using Iterator instead of Iterable in bytestream types

* Update docs/advanced.md

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

* Consistent typing imports across tranports

* Update docs/advanced.md

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

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2021-03-24 12:36:34 +00:00
Tom Christie
6cb1672459
Fix some cases of merging with base_url (#1532)
* Fix some cases of merging with base_url

* Fix for joining relative URLs

* Improve code comment in _merge_url implementation
2021-03-24 10:51:33 +00:00
Adam Hooper
0f280af8b1
map_exceptions in request.aclose() (#1465)
* map_exceptions in request.aclose()
2021-02-17 11:32:43 +00:00
Tom Christie
084f35648b
Allow handler to optionally be async when MockTransport is used with AsyncClient (#1449) 2021-02-17 11:10:21 +00:00
Aber
02a692aba5
Handle default ports in WSGITransport (#1469)
* Maybe port is `None`

https://www.python.org/dev/peps/pep-3333/#environ-variables

> SERVER_NAME, SERVER_PORT
> When HTTP_HOST is not set, these variables can be combined to determine a default. See the URL Reconstruction section below for more detail. SERVER_NAME and SERVER_PORT are required strings and must never be empty.

* Add unit test

* Compute default port

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2021-02-16 13:33:17 +01:00
Tom Christie
89fb0cbc69
Add HTTPTransport and AsyncHTTPTransport (#1399)
* Add keepalive_expiry to Limits config

* keepalive_expiry should be optional. In line with httpcore.

* HTTPTransport and AsyncHTTPTransport

* Update docs for httpx.HTTPTransport()

* Update type hints

* Fix docs typo

* Additional mount example

* Tweak context manager methods

* Add 'httpx.HTTPTransport(proxy=...)'

* Use explicit keyword arguments throughout httpx.HTTPTransport

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2021-01-08 10:23:56 +00: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
SarunasAzna
86964054d6
Allow tuple as input of query parameters. (#1426)
* Allow tuple as input of query parameters.

In the documentation it is stated that params can be dict, string or two
tuples. This allows to used two tuples. Previously it was possible to
use only tuple inside a list.

* tests for two tuples

* use isinstance to check the type of query params

* change list|tuple to in Sequence

* update documentation

* fix typing
2020-12-12 18:38:37 +01:00
Andrés Álvarez
28cbe77676
Add repr to Cookies for displaying available cookies (#1411)
* Add repr to Cookies for displaying available cookies

* Add unit test

* Simplify repr

* Remove file
2020-12-03 22:06:42 +01:00
Florimond Manca
9005bd5df6
Properly encoded slashes when using base_url (#1407) 2020-12-02 13:01:11 +00:00
Tom Christie
d0835da230
Add keepalive_expiry to Limits config (#1398)
* Add keepalive_expiry to Limits config

* keepalive_expiry should be optional. In line with httpcore.
2020-11-25 15:32:37 +00:00
Tom Christie
27df5e49c7
Support for chunk_size (#1277)
* Support iter_raw(chunk_size=...) and aiter_raw(chunk_size=...)

* Unit tests for ByteChunker

* Support iter_bytes(chunk_size=...)

* Add TextChunker

* Support iter_text(chunk_size=...)

* Fix merge with master

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-11-25 15:28:06 +00:00
Tom Christie
c4d2e6fa28
Add support for Mount API (#1362)
* Add support for Mount API

* Add test cases

* Add test case for all: mounted transport

* Use 'transport' variable, in preference to 'proxy'

* Add docs for mounted transports
2020-11-24 10:35:51 +00:00
plotski
589c6e0f2f
Include invalid name/value when raising TypeError in DataField (#1368) 2020-11-05 10:46:22 +00:00
Florimond Manca
2f54548dad
Drop unecessary host="localhost" in https_server fixture to fix CI build (#1367) 2020-10-24 23:25:31 +02:00
Tom Christie
07229b8dff
Close AsyncClient properly in test_async_next_request (#1361) 2020-10-14 08:38:53 +02:00
Simon Willison
ca5f524943
Add raw_path to scope in ASGITransport (#1357)
* Add raw_path to scope in ASGITransport, closes #1356

* Tweaked test
2020-10-09 16:46:26 +01:00
Tom Christie
0123bca335
Force lowercase ASGI headers (#1351)
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-10-08 12:04:10 +01:00
cdeler
7fda99fcef
Correctly handle ipv6 addresses as a part of URL (#1349)
* Correctly handle ipv6 addresses as a host

* Fixed typo

* Added an extra rfc reference

* Update tests/models/test_url.py

* Update tests/models/test_url.py
2020-10-08 11:37:13 +03:00
Tom Christie
c725387b2d
Preserve header casing (#1338) 2020-10-06 14:57:10 +01:00
Tom Christie
0eed6a3734
Drop .next()/.anext() in favour of response.next_request (#1339)
* Drop response.next()/response.anext() in favour of response.next_request

* Drop NotRedirectResponse
2020-10-06 14:53:07 +01:00
Tom Christie
2a2bbe58a6
Tighten client closed-state behaviour (#1346)
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-10-06 13:38:05 +01:00
Tom Christie
3f51392bea
Add response.next_request (#1334)
* Add response.next_request

* Add response.next_request

* Add response.next_request to the docs
2020-10-01 13:52:03 +01:00
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
cdeler
0a38695063
Fixed warnings in unit tests suite, caused by #1127 PR (#1137) 2020-08-06 13:41: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
Tom Christie
e5f87434a5
Use get_list consistently (#1119)
* Use get_list consistently

* Ensure DeprecationWarning on getlist vs. get_list
2020-08-02 11:33:50 +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
26cd4f54e8
Switch to more concise Timeout parameters (#1111)
* Switch to more concise Timeout parameters

* Update docs

* Rename attributes

Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-08-01 19:59:01 +01:00
Florimond Manca
a9284214e2
Make Headers.keys(), Headers.values() and Headers.items() return set-like views (#1114) 2020-08-01 20:15:15 +02: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
2ba9c1ed90
Consistent multidict methods (#1089)
* Consistent multidict methods

* Consistent multidict methods and behaviour

* Update httpx/_models.py

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

* Update httpx/_models.py

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

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-07-31 11:46:35 +01:00
Tom Christie
dba83d45a5
httpx.Timeout must include a default (#1085)
* httpx.Timeout must include a default

* Tweak docstring

* Gentle deprecation for mandatory default on httpx.Timeout(...)

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-07-31 11:41:53 +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
Can Sarıgöl
926a55a84f
Included create_ssl_context function to create the same context with SSLConfig and serve as API (#996)
* Included create_ssl_context function to create the same context with SSLConfig and serve as API.

* Changed create_ssl_context with SSLConfig into the client implementation and tests.

* Dropped the __repr__ and __eq__ methods from SSLConfig and removed SSLConfig using from tests

* Fixed test issue regarding cert_authority trust of ssl context

Co-authored-by: Tom Christie <tom@tomchristie.com>
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-07-27 19:46:46 +01:00
Tom Christie
35f09d1394
Single consistent name for status codes (#1088)
* Single consistent name for status codes
* Gentle deprecation for httpx.StatusCode
2020-07-27 14:35:01 +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
Tom Christie
247ee0dc49
Drop private Origin model (#1070)
* Drop private Origin model

* Drop Origin from docs

* Update tests/test_utils.py

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

* Drop full_path test

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-07-23 09:54:45 +01:00
Tom Christie
20f4911e80
Fixes for LineDecoding (#1075)
* Fixes #1033 - Ensure that text that spans 3 invocations before newline is handled - don't clobber the buffer between invocations that haven't seen any lines.
This seems like a one character fix + the test.

* Update the tests.

* Undo formatting/indentation.

* Update long comment.

* Fix trailing cr line decoding

Co-authored-by: Sheridan C Rawlins <scr@verizonmedia.com>
2020-07-23 09:45:35 +01:00
Tom Christie
8ed7e52a37
Drop fullpath setter (#1069) 2020-07-23 09:43:11 +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
Sheridan C Rawlins
ad5e6eb8b0
Fixes #1033 - Ensure that text that spans 3 invocations before newline is handled - don't clobber the buffer between invocations that haven't seen any lines. (#1034)
Fixes #1033 - Ensure that text that spans 3 invocations before newline is handled - don't clobber the buffer between invocations that haven't seen any lines.
2020-07-21 10:33:45 +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
ff93a011a4
Support QueryParams(None) (#1060) 2020-07-16 11:16:29 +01: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
Florimond Manca
3230cb3133
Add missing Response.next() (#1055) 2020-07-07 10:54:50 +02:00
Taneli Hukkinen
6a20cfc0b8
Simplify bytes to hex string conversion (#1049)
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-07-05 12:16:55 +02:00
Florimond Manca
bacc2d1835
Map HTTPCore exceptions (#1044)
* Map HTTPCore exceptions

* Expose new TimeoutException
2020-07-03 15:56:10 +02:00
Florimond Manca
fab427972b
Add exceptions missing from top-level package (#1045)
* Expose missing exceptions: CloseError, ConnectError, ReadError, WriteError

* Lint
2020-07-03 15:18:24 +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
euri10
4d287956fd
Add support for multiple files per POST field (#1032)
* Changed RequestFiles type

* Changed RequestFiles type 2

* Added test for multiple files same field

* Lint

* Mypy no idea

* Added doc

* Fixed some docs typos

* Checking the right instance type and deleting the mypy ignore

* Docs clarification

* Back on images form field, with other files modified
2020-06-24 19:17:27 +02:00
Florimond Manca
838f417ce0
Run ASGI tests on trio too (#1020) 2020-06-13 19:42:36 +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
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
Florimond Manca
440b5ab95f
Remove unused concurrency test utils (#989) 2020-05-24 11:38:24 +02:00
Florimond Manca
ab9ace2749
Fix bytes support in multipart uploads (#974) 2020-05-21 16:25:31 +02:00
Tom Christie
991915a935
Rename pool limit options (#968)
* Pass proxy_url

* Rename hard_limit/soft_limit

* Use 'warn_deprecated' function

* Update PoolLimits docs

* Linting

* Update httpcore dependancy

* Update port in Transport API to be 'Optional[int]'
2020-05-21 13:26:20 +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
Jamie Hewland
d568ecda53
ASGI: Wait for response to complete before sending disconnect message (#919)
* asgi: Wait for response to complete before sending disconnect message

* Dial back type checking + remove concurrency module

* Remove somewhat redundant comment
2020-05-12 10:06:53 +01:00
Jamie Hewland
8710079d5d
asgi: Send http.disconnect message on receive() after response complete (#909)
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-05-01 11:51:35 +02:00
Florimond Manca
5829ecb648
Implement streaming multipart uploads (#857)
* Implement streaming multipart uploads

* Tweak seekable check

* Don't handle duplicate computation yet

* Add memory test for multipart streaming

* Lint

* 1 pct is enough

* Tweak lazy computations, fallback to non-streaming for broken filelikes

* Reduce diff size

* Drop memory test

* Cleanup
2020-04-10 20:40:04 +02:00
Florimond Manca
af75908b7a
Drop concurrency backends (#901)
* Drop concurrency backends

* Put back as_network_error for use in urllib3 dispatcher
2020-04-10 18:48:01 +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
Ed Singleton
94323f98ac
Fix support for generator-based WSGI apps (#887)
* Handle generator WSGI app

* Lint code

* Add type annotations

* Add more tests

* Refactor test to use application_factory

* Remove content length as it's misleading

* Add test for WSGI generator

* Add test for empty generator

* Remove previous tests

* Move docstring to a comment

* Fix whitespace

* Fix name of function

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

* Update tests/test_wsgi.py

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

* Update tests/test_wsgi.py

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

* Update httpx/_dispatch/wsgi.py

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

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-03-29 13:13:01 +02:00
Dima Boger
939f3ce7ce
Add content-length header for empty bytestream (#866)
Also, fixed related tests
2020-03-28 16:05:06 +01:00
Dima Boger
430285f55b
Fix multipart edge cases with data={} and/or files={} (#861)
* Add reproducible test example for empty multipart

* Possible fix for empty combination of files/data

* Return bytestream with empty data/files

* Remove content-length in test

Co-authored-by: florimondmanca <florimond.manca@gmail.com>
2020-03-16 22:34:50 +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
Tom Christie
3333152b54
Don't support broken dict-of-dicts case for data argument (#811) 2020-03-02 10:34:04 +00: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
Tim Gates
c2eb0bd40f Fix simple typo: conncurrent -> concurrent (#793)
Closes #792
2020-01-26 01:24:41 -05:00
Yeray Diaz Diaz
b23420392e
Detect credentials in proxy URLs and create Proxy-authorization header (#780)
* Detect auth in proxy URLs and create Proxy-authorization header

* Add credentials and SOCKS details to proxy documentation

* Use URL.copy_with to remove credentials from URL
2020-01-20 13:50:50 +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
780d1843ca
Support both zlib and deflate encodings (#758)
* Support both zlib and deflate encodings

* Helpful test docstrings
2020-01-14 09:00:52 +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
Andrés Álvarez
2b92a78c41 Drop Origin from public API (#688)
- Drop the url.origin property.
  - Drop Origin from the top-level export.
  - Use origin = Origin(url) in our internal usage, rather than
    url.origin.

Closes #656

Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-01-07 10:39:47 +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
Tom Christie
6ac49dacdd
Drop run and run_in_threadpool (#710)
* Drop run and run_in_threadpool

* Fix server restart errors

* Re-introduce 'sleep' as a concurrency test utility

* Simpler test concurrency utils

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-01-06 11:14:43 +00:00
Florimond Manca
bd57b650a8 Release max_connections for keepalive connections when closing the connection pool (#721) 2020-01-06 11:13:06 +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
79a9748ae6
Load SSL Context on init (#709) 2020-01-02 16:52:23 +00:00
Tom Christie
f5eaec7ab3
More coverage improvements (#711)
* More coverage improvements

* Drop redundant 'sleep' usage in test utils
2020-01-02 15:33:26 +00:00
Tom Christie
11e7604d1a
Sync streaming interface on responses (#695)
* Sync streaming interface on responses

* Fix test case

* Test coverage for sync response APIs

* Address review comments
2020-01-02 12:56:11 +00: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
Gabriel Strauss
de8b95533d Adds check to enforce single consumption of AsyncIteratorStream. (#697) 2019-12-31 12:01:43 +00:00
Tom Christie
6a1ee0eb97
response.elapsed now reflects entire request/response time. (#692)
* Changed behaviour of elapsed on response

* Fixed api docs for Response elapsed

* Minor tweaks to 'request.elapsed'

* Response instantiated with content should have elapsed==0

* Fix elapsed time on immediately closed responses.
2019-12-29 16:56:18 +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
e9ebd1df98 Drop per-request cert, verify, and trust_env (#617)
* Drop per-request cert/verify/trust_env

* Remove cert/verify from the dispatcher API

* Apply lint

* Reintroduce cert/verify/trust_env on client methods, with errors
2019-12-29 15:01:20 +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
Florimond Manca
56c8edaf66
Make 'request' non-optional on responses (#666)
* Make 'request' non-optional on Response

* Lint

* Remove remaining mention to null request
2019-12-21 15:38:25 +01:00
Andrés Álvarez
e34df7a7a1 Rename concurrency directory to backends (#662)
Closes #659
2019-12-20 16:53:42 +00: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
74e5115b86
params argument on URL should merge, not replace. (#653) 2019-12-20 10:46:35 +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
52c2c9762f
Bump up flow control defaults (#629)
* Bump up flow control defaults

* Linting

* Simplify mock HTTP/2 stream in tests
2019-12-12 11:57:53 +00:00
Tom Christie
499de51f2b
Keep-alive timeouts. (#627)
* Add .time() to backend

* Add connection timeouts

* Add test case for keep alive timeouts

* Update httpx/dispatch/connection_pool.py

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

* Cleanups from review

* Use .expires_at, rather than .timeout_at
2019-12-12 11:52:49 +00:00
Tom Christie
02d16bfb34 Trivial-case test for response.elapsed 2019-12-09 17:12:20 +00:00
Tom Christie
3124a38123
Minor config cleanup (#621) 2019-12-09 10:59:55 +00:00
Tom Christie
eba29da632
Drop 'fork' (#619) 2019-12-08 19:52:46 +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
bc54dd0399
Backend operations like .read(), .write() now have a manadatory timeout argument. (#611) 2019-12-07 11:09:58 +00: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
Florimond Manca
c38fd68ed7 Drop BackgroundManager in favor of fork(func1, func2) (#603)
* Drop BackgroundManager in favor of fork(func1, func2)

* Please mypy
2019-12-06 10:49:24 +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
dad379736d
Fix Timeout -> TimeoutException in test case (#598) 2019-12-05 11:03:27 +00:00
Tom Christie
2f54b200de
Allow default+override timeout style (#593)
* Allow styles like: httpx.Timeout(5.0, pool_timeout=None)

* Update timeout docs

* Minor tweaks to sub headings in timeout docs

* Fixing up Timeout docs

* RequestTimeout -> TimeoutException

* Tweak timeout docs
2019-12-05 09:38:48 +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
c033ed1b65
TimeoutConfig -> Timeout (#591) 2019-12-04 11:39:45 +00:00
Tom Christie
5076952202
Rename http2 switch (#586)
* 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

* Rename HTTP2 switch on client

* http_2 -> http2
2019-12-02 19:52:29 +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