Commit Graph

587 Commits

Author SHA1 Message Date
Can Sarıgöl
c5248e6c20 Run SSLConfig cert loading in threadpool (#209) 2019-08-14 21:30:01 -05:00
Tammo Behrends
bebedcbd5d Explicitly check is_redirect in simple test case (#208) 2019-08-14 06:22:12 -05:00
Seth Michael Larson
80dc3e274e
Use nox for automation and CI (#128) 2019-08-13 08:39:35 -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
Quentin Pradet
ebbc003c55 Fix invalid Content-Encoding header test (#197) 2019-08-09 08:10:59 -05:00
Stephen Brown II
fde30b8d14 Use pathlib.Path instead of os.path functions (#188) 2019-08-08 21:42:25 -05:00
Andreas Bernacca
de91fdfa16 Ignore Content-Encoding headers that are invalid (#196) 2019-08-08 21:33:55 -05:00
halbow
92fbe5fd87 Added base class HTTPError with request/response attribute (#162) 2019-08-06 08:20:48 -05:00
Seth Michael Larson
9142a893ff Move HSTS preload checking to client (#184) 2019-08-01 10:26:45 +01:00
Can Sarıgöl
919e8d3f9b added netrc support (#177) 2019-08-01 09:32:00 +01:00
Stephen Brown II
40849bffcb Update IDNA encoding to 2008 spec (#161)
* Update IDNA encoding to 2008 spec

* Add Unicode IDNA Compatibility Processing

* Parametrize idna test

* Use rfc3986 iri_reference for IDNA names

* Add test for IRI object

* Remove test_iri as this interface has been removed
2019-07-31 14:41:40 +01:00
Tom Christie
66754ad0c5
Tweak query param types (#175)
* Tweak query param types

* Handle primitive data types for queryparams

* QueryParam keys as str-only, not PrimitiveData
2019-07-31 00:27:20 +01:00
Nik
fb17459335 Fixed multipart header params encoding (#167) 2019-07-28 22:16:37 -05:00
Stephen Brown II
72e6f47897 Allow setting headers at the Client level (#159) 2019-07-28 20:39:35 -05:00
Seth Michael Larson
3ba2e8c328
Switch hosts on HSTS preload to HTTPS (#151) 2019-07-28 12:02:21 -05:00
Can Sarıgöl
7e9110b978 Add additional flake8 plugins (#157) 2019-07-28 11:40:05 -05:00
Tom Christie
00e4fdb05d Fix URL.join(...) (#144) 2019-07-25 17:01:03 -05:00
Tom Christie
ec365c0e8e
Check disconnections on connection reacquiry (#145)
* Detect EOF signaling remote server closed connection

Raise ConnectionClosedByRemote and handle on `send`

* Fix linting

* Use existing NotConnected exception

* Add `Reader.is_connection_dropped` method

* Check connection before sending h11 events as well

* Add test covering connection lost before reading response content

* Check for connection closed on acquiring it from the pool

* Clean up ConnectionPool logic around reaquiry of connections
2019-07-25 22:52:41 +01:00
Stephen Brown II
8db36ed6a5 Allow string comparison for URL().__eq__ (#139) 2019-07-24 16:28:16 +01:00
Tom Christie
2d09d5b36c
Renaming -> httpx (#129)
* Renaming -> httpx

* Renaming to httpx
2019-07-19 15:15:16 +01:00
ambrozic
0e8dae4815 Multipart data values encoding (#121)
* multipart data values encoding (#119)

* Update test_multipart.py
2019-07-18 12:00:02 +01:00
Seth Michael Larson
c1044cab84 Start using flake8, fix lint issues (#126) 2019-07-18 11:41:50 +01:00
Seth Michael Larson
ba83e29aee Support client cert passwords, new TLS options (#118)
* Support client cert passwords, new TLS options

* Update test_config.py

* Switch to try-except for post_handshake_auth=True

SSLContext.post_handshake_auth raises AttributeError if the property is available but cannot be written to (needs OpenSSL 1.1.1+)

* Also try-except for hostname_checks_common_name=False

* Custom implementation of trustme.CA() that emits encrypted PKs

* lint

* Split name of test

* Updates from review comments

* Don't load default CAs yet
2019-07-16 10:08:57 +01:00
Yeray Diaz Diaz
5442006a41 Encoding detection in Response.json (#116)
* Use response text on `json`

Pass kwargs to the loads call

* Add failing test demonstrating corner case

* Copy `guess_json_utf` function from requests

* "Fix" type hinting and lint

* Actually add tests_utils.py
2019-07-11 17:14:58 +01:00
Tom Christie
025240c3b3
Check for connection aliveness on pool re-acquiry (#111)
* Check for connection aliveness on pool re-acquiry

* Test for connection re-acquiry with HTTP/2

* nocover on HTTP/1.1 ConnectionResetError, since we're testing the equivelent on HTTP/2

* Fix setup.py to read version from __version__
2019-07-08 15:57:29 +01:00
Tom Christie
fe1f9ed119
Minor tweaks in line with requests behavior (#110) 2019-07-03 10:33:38 +01:00
Tom Christie
5326cd1a20
Version 0.6.4 (#105)
* Read/Write timeout modes

* Read/Write timeout modes

* Tweaks for read/write timeout modes

* Version 0.6.4

* Make slow_response slower for timeout test
2019-06-25 13:24:12 +01:00
Tom Christie
f4f05e343c
Read/Write timeout modes (#104)
* Read/Write timeout modes

* Read/Write timeout modes
2019-06-25 12:54:14 +01:00
Tom Christie
b9c8a1505e
Handle early connection closes (#103)
* Refactoring h11 implementation

* More h11 refactoring

* Support early connection closes on H11 connections

* Tweak comment

* Refactor concurrent read/writes

* Drop WriteTimeout masking

* Linting

* Use concurrent read/writes for HTTP2

* Push background sending into ConcurrencyBackend
2019-06-24 16:53:42 +01:00
updatatoday
f9e3ad4c16 Fixed response repr. (#101)
* Fixed response repr.

* Fixed response repr tests.
2019-06-23 11:37:00 +01:00
Tom Christie
9d5aaff5bc Support Client(base_url=...) 2019-06-21 15:03:01 +01:00
Tom Christie
bb8697011d
Support WSGI and ASGI apps. (#94)
* Add 'Client(app=...)' support

* Add ASGI support with Client(app=app)

* Improve exc cases when using client with ASGI

* Tighten up exception handling when using as a test client

* Fix up stream I/O for WSGI/ASGI apps

* Docs for WSGI/ASGI integration
2019-06-18 15:53:33 +01:00
Tom Christie
56a7943206
Int status codes (#92)
* Use plain int for response.status_code

* Linting
2019-06-17 16:53:39 +01:00
Tom Christie
6a44b05e4d
Multipart support (#90)
* Multipart support

* Test compat with 3.6
2019-06-17 14:38:24 +01:00
Tom Christie
7c6fb5c6ca
Tweaks (#89)
* Close redirect responses

* History should not be reverse-order

* History should not be reverse-order

* Docs updates
2019-06-13 16:19:39 +01:00
Tom Christie
c9747aa357
http3 (#86)
* Start fleshing out documentation

* Docs work

* http3

* Update docs

* Include lowercase status codes, for requests compat

* Updating docs

* Docs tweaks
2019-06-12 15:02:16 +01:00
Tom Christie
0cbf3c7581
Sync or Async dispatch (#83)
* Support thread-pooled dispatch

* Add ConcurrencyBackend.run

* Initial work towards support byte-iterators on sync request data

* Test case for byte iterator content

* byte iterator support for RequestData

* Add BaseResponse

* Bridge sync/async data in SyncResponse

* Add BaseClient

* SyncResponse -> Response

* Tweaking type annotation

* Distinct classes for Request, AsyncRequest

* Tweak is_streaming, content in BaseRequest

* Stream handling moves to client

* Handle mediating to AsyncResponse from a standard sync Dispatcher class

* Working on thread-pooled dispatcher

* Support threaded dispatch, inc. streaming requests/responses

* Increase test coverage

* Coverage and tweaks

* Include Accept and User-Agent headers by default
2019-06-10 12:26:03 +01:00
Tom Christie
76bc6c6dea
Drop Host header for HTTP/2 (#82) 2019-05-28 14:39:57 +01:00
Tom Christie
1970912c41 Drop unintended test module 2019-05-24 12:10:06 +01:00
Tom Christie
c12c271276
Status code tweaks (#77)
* Add top-level API

* Add tests for top-level API

* Further work towards parallel support

* StatusCode tweaks

* Drop erronous commit
2019-05-24 10:27:35 +01:00
Tom Christie
95740415db
Work on bringing API into parity with requests. (#76)
* Finesse timeout argument.

* Drop unused imports

* Add 'cert' and 'verify' arguments
2019-05-23 16:21:00 +01:00
Tom Christie
fc627f3387
Add top-level API (#75)
* Add top-level API

* Add tests for top-level API
2019-05-20 14:30:52 +01:00
Tom Christie
5a63d313f0 Add json interfaces 2019-05-17 14:43:22 +01:00
Tom Christie
2116d44777 Add response.json() 2019-05-17 14:29:36 +01:00
Tom Christie
a284d0b2ea Tweak test naming 2019-05-17 13:49:24 +01:00
Tom Christie
bb703771b3 query_params -> params 2019-05-17 13:09:31 +01:00
Tom Christie
c6287ed782 query_params -> params 2019-05-17 13:06:26 +01:00
Tom Christie
feae0a895d
Cookie support (#73)
* Initial pass at cookie support
* Add Cookies model
* Support cookie persistence
2019-05-17 12:51:00 +01:00
Tom Christie
f63148aa73 Support cookie persistence 2019-05-17 12:41:36 +01:00
Tom Christie
24b6923669 Add Cookies model 2019-05-17 11:45:02 +01:00
Tom Christie
1e0409c105 Add Cookies model 2019-05-17 10:00:56 +01:00
Tom Christie
4a3325f87b Initial pass at cookie support 2019-05-16 16:44:33 +01:00
Tom Christie
fc16d31d62
100% test coverage (#71) 2019-05-16 11:14:21 +01:00
Yeray Diaz Diaz
b8b3714d8e Add test for write timeout error (#67)
* Add test for write timeout error
* Bump up write data 10x
2019-05-16 11:00:45 +01:00
Tom Christie
3ed08857ee
Drop unused interface on ConnectionStore (#70) 2019-05-16 10:56:05 +01:00
Tom Christie
4fe6bc058a
Add 100-continue test (#68) 2019-05-16 10:21:24 +01:00
Tom Christie
5afa7dd5cc
Auth (#65)
* Initial work towards auth

* Add auth support

* Add test for custom auth

* Support auth-in-URL

* Support auth-on-session
2019-05-15 16:43:35 +01:00
Yeray Diaz Diaz
2e9ab2e904 Include URL.__hash__ in test (#64)
* Include URL.__hash__ in test

* Add test for URLs being used in a set

Remove hash assertion on test requests

* Cleanup models.py

* Use membership test instead of equality to avoid ordering problems
2019-05-15 14:30:00 +01:00
Tom Christie
abec2e85e9
Merge pull request #61 from yeraydiazdiaz/test-config
Test config
2019-05-14 14:36:37 +01:00
Tom Christie
8f4abe057b Linting 2019-05-14 14:35:55 +01:00
Tom Christie
73d5fca823 repr change: <SyncResponse ...> -> <Response ...> 2019-05-14 14:35:47 +01:00
Tom Christie
e40b0bfe83 Tidy up redirect tests 2019-05-14 14:34:43 +01:00
Tom Christie
3acc31621c Support alternate concurrency backends from client & rejig tests 2019-05-14 14:11:13 +01:00
Yeray Diaz Diaz
8d53257915 Add tests for config
Separate cert and key paths into its own fixture
2019-05-14 13:37:10 +01:00
Tom Christie
2694c48492 Add ConcurrencyBackend interface 2019-05-14 10:25:31 +01:00
Tom Christie
87cab4c5a4
Merge pull request #56 from yeraydiazdiaz/test-additional-http-methods
Additional tests for SyncClient
2019-05-14 09:33:34 +01:00
Tom Christie
c27c635f2f
Merge pull request #57 from yeraydiazdiaz/test-https
Add test to https server
2019-05-14 09:32:09 +01:00
Yeray Diaz Diaz
fe5a3b875b Add tests for additional HTTP methods on async client
Add tests for raise_for_status and SyncResponse properties
2019-05-13 21:01:13 +01:00
Yeray Diaz Diaz
e46ee49974 Rename test_asnyc_client > test_async_client 2019-05-13 20:41:50 +01:00
Yeray Diaz Diaz
b4ab7bb619 Additional tests for SyncClient 2019-05-13 20:39:24 +01:00
Yeray Diaz Diaz
b3af383923 Add test to https server
Add `https_server` test fixture
2019-05-13 20:33:16 +01:00
Tom Christie
3b4439039d Use stdlib status codes 2019-05-13 14:34:24 +01:00
Tom Christie
8627b62863 Switch to sync-by-default 2019-05-13 13:48:08 +01:00
Tom Christie
d6628ca88a Drop 'adapters' 2019-05-13 11:54:51 +01:00
Taoufik
a260d0ace8
Remove print 2019-05-08 17:31:06 +02:00
Tom Christie
e91c69d2ad Support url-encoded data in requests 2019-05-08 14:59:41 +01:00
Tom Christie
19542f2c3c Request(content=...) -> Request(data=...) 2019-05-08 14:45:06 +01:00
Tom Christie
e99ffbd7ac Increase test coverage 2019-05-08 13:52:26 +01:00
Tom Christie
faededae59 Add query_params support 2019-05-08 12:43:06 +01:00
Tom Christie
211bef130b Add QueryParams class 2019-05-08 12:01:48 +01:00
Matus Ferech
c628eb061c
Test raise_for_status 2019-05-04 17:44:35 +02:00
Matus Ferech
0629e55f98
Add status_code endpoint 2019-05-04 17:44:06 +02:00
Tom Christie
6b60d95a4d Truckin' on 2019-05-01 14:35:23 +01:00
Tom Christie
0ca1c844cd Truckin' on 2019-05-01 12:39:16 +01:00
Tom Christie
d7cf8bbf36 Media types with 'text/' should default to iso-8859-1 2019-05-01 12:32:31 +01:00
Tom Christie
118d94b58c
Merge pull request #21 from yeraydiazdiaz/wait-for-connection-close
Add `raw` method to SyncResponse
2019-05-01 11:36:47 +01:00
Tom Christie
e1ecb360d9 Carefulness with encoding everywhere 2019-05-01 11:32:03 +01:00
Tom Christie
b948798414 Add idna support. More tests. 2019-05-01 10:58:58 +01:00
Tom Christie
5d552eba69
Update test_sync.py 2019-05-01 09:49:08 +01:00
Tom Christie
20bc1f3530
Merge branch 'master' into wait-for-connection-close 2019-05-01 09:46:19 +01:00
Tom Christie
302fe93df9 Use rfc3986 for URL handling 2019-04-30 17:39:40 +01:00
Tom Christie
fd9823e59c Add test for explicitly setting the encoding to use 2019-04-30 16:37:10 +01:00
Tom Christie
d8df61b44b Add response.text and response.encoding 2019-04-30 16:35:25 +01:00
Tom Christie
4255d41846 Prefer 'content' over 'body' 2019-04-30 15:08:24 +01:00
Tom Christie
4c5511313c Response.content 2019-04-30 14:58:43 +01:00
Tom Christie
dea4d42c6d Rejig test and tighten up models API 2019-04-30 13:52:37 +01:00
Tom Christie
d7619a92a8 Finessing interface 2019-04-30 11:26:11 +01:00
Tom Christie
d652479b07 response.next() 2019-04-29 17:14:08 +01:00
Tom Christie
51ae3e1e96
Merge branch 'master' into decoding-exceptions 2019-04-29 16:58:00 +01:00
Tom Christie
450ea25b5a Add await response.next() interface 2019-04-29 16:18:41 +01:00
Tom Christie
b392b7ea59 Test allow_redirects=False 2019-04-29 16:08:31 +01:00
Tom Christie
05e0649e8f Nicer headers interface 2019-04-29 16:05:05 +01:00
Tom Christie
83d322f736 Handle body in redirects 2019-04-29 15:25:44 +01:00
Tom Christie
4f23ab4f0d Rejig request preparing 2019-04-29 14:25:24 +01:00
Yeray Diaz Diaz
6b4742303e Raise single DecodingError
Fix typo
2019-04-29 13:38:36 +01:00
Tom Christie
041813bc4a Redirections 2019-04-29 12:35:58 +01:00
Tom Christie
8b4ef87a89 Redirect tests 2019-04-29 12:12:08 +01:00
Tom Christie
e09fc3741f Restructuring 2019-04-29 11:54:48 +01:00
Yeray Diaz Diaz
99dc1a99d2 Add raw method to SyncResponse 2019-04-27 17:16:41 +01:00
Yeray Diaz Diaz
bdc218f8e6 Wrap decoding errors with custom exceptions 2019-04-27 16:39:53 +01:00
Tom Christie
8a29a0a1ad Rollin' 2019-04-26 17:00:47 +01:00
Tom Christie
fab6fcd397 Adapters 2019-04-26 15:34:04 +01:00
Tom Christie
6d35506277 Drop unneccessary __hash__ methods 2019-04-25 17:05:40 +01:00
Tom Christie
28c505a70f Tighten up connection acquiry/release 2019-04-25 15:31:47 +01:00
Tom Christie
286f04f1a6 Add PoolSemaphore 2019-04-25 12:57:18 +01:00
Tom Christie
9ab607d8a3 More HTTP/2 tests 2019-04-25 12:23:20 +01:00
Tom Christie
a44190ff24 Stream refactoring and HTTP/2 test case 2019-04-25 12:05:23 +01:00
Tom Christie
53f3dc4a66 First pass at HTTP/2 support 2019-04-24 15:48:18 +01:00
Tom Christie
b7d315af3b Module renaming 2019-04-23 14:25:47 +01:00
Tom Christie
c9b9ea07b6 Add SyncResponse.stream 2019-04-23 11:31:51 +01:00
Tom Christie
4a36ec74c7 Add SyncConnectionPool 2019-04-23 11:12:37 +01:00
Tom Christie
5b2f3ed656 Use different hosts in pool acquiry timeout test. 2019-04-23 09:37:10 +01:00
Tom Christie
275443c4a1 Add client.request 2019-04-23 09:34:41 +01:00
Tom Christie
be774980ce Refactor to request = Client.send(request) 2019-04-22 17:33:43 +01:00
Tom Christie
fc7cf9def6 Add response.reason 2019-04-18 11:41:13 +01:00
Tom Christie
42c0e06c8c Allow per-request timeout/ssl config 2019-04-18 10:36:30 +01:00
Tom Christie
74c9048ba2 Add ConnectTimeout test 2019-04-18 09:38:29 +01:00
Tom Christie
148818c212 Add PoolTimeout, and timeout tests 2019-04-17 17:38:03 +01:00
Tom Christie
29cb53f09e Add soft_limit and hard_limit support to PoolLimits 2019-04-17 16:54:18 +01:00
Tom Christie
5f3a8bdb4d Connection pooling 2019-04-16 15:58:38 +01:00
Tom Christie
ee6f42a8f4 Exclude unused code lines 2019-04-16 12:18:38 +01:00
Tom Christie
042dd22058 Add auto headers on Request 2019-04-16 12:14:20 +01:00
Tom Christie
39b57c939d Add support for gzip, deflate, and brotli decoding 2019-04-16 11:26:28 +01:00
Tom Christie
ba1953cdd0 Linting 2019-04-06 13:20:47 +01:00
Tom Christie
86263fa073 Connections 2019-04-06 13:18:39 +01:00
Tom Christie
6a4376b202 Connections 2019-04-05 17:49:59 +01:00
Tom Christie
30530d446d Stuff 2019-04-04 18:28:38 +01:00