Commit Graph

54 Commits

Author SHA1 Message Date
Tom Christie
8e36f2bc68
Introduce new SSLContext API & escalate deprecations. (#3319)
Co-authored-by: Kar Petrosyan <92274156+karpetrosyan@users.noreply.github.com>
Co-authored-by: T-256 <132141463+T-256@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-10-28 14:30:08 +00:00
dependabot[bot]
7354ed70ce
Bump the python-packages group with 8 updates (#3156) 2024-04-09 21:38:43 +01:00
Florimond Manca
ef06f7d076
Drop private imports in tests/conftest.py (#2569)
Co-authored-by: Tom Christie <tom@tomchristie.com>
2023-02-09 15:54:53 +00:00
Florimond Manca
7488b15226
Drop private imports from test_exceptions.py (#2571) 2023-02-08 19:35:52 -05: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
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
Martijn Pieters
57aa5b08a4
Enable no_implicit_reexport (#2475)
- Add explicit exports for names imported from `_compat`
- Correct imports of `URL` (from `._urls`, not via `._models`)
- Correct import of the uvicorn `Server` class

Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-11-30 13:11:22 +00:00
Martijn Pieters
2d37321842
Typing: enable warn_return_any (#2477) 2022-11-30 13:08:02 +00:00
Martijn Pieters
049afe5b25
Typing: enable disallow_incomplete_defs (#2476)
The only places mypy reports issues is in the test suite.
2022-11-30 09:04:54 +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
waterfountain1996
4c307488cd
Suppress binary output on the command line (#2049) (#2076) 2022-02-09 15:40:39 +00:00
Tom Christie
ee9250d60b
Add cli support (#1855)
* Add cli support

* Add setup.py

* Import main to 'httpx.main'

* Add 'cli' to requirements

* Add tests for command-line client

* Drop most CLI tests

* Add test_json

* Add test_redirects

* Coverage exclusion over _main.py in order to test more clearly

* Black formatting

* Add test_follow_redirects

* Add test_post, test_verbose, test_auth

* Add test_errors

* Remove test_errors

* Add test_download

* Change test_errors - perhaps the empty host header was causing the socket error?

* Update test_errors to not break socket

* Update docs

* Update version to 1.0.0.beta0

* Tweak CHANGELOG

* Fix up images in README

* Tweak images in README

* Update README
2021-09-14 09:44:43 +01:00
Michał Górny
8c64e0c65f
Inline SERVER_SCOPE and remove typing_extensions requirement (#1773) 2021-07-26 15:08:58 +01:00
Almaz
b839478661
Replace for loops with comprehensions (#1759) 2021-07-21 14:30:55 +01:00
Marcelo Trylesinski
3231211aa3
👷 Add Python 3.10 beta to the CI (#1682)
* 👷 Add Python 3.10 beta to the CI
* ⬆️ Upgrade pytest from 5.* to 6.*
2021-06-15 11:59:30 +01: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
Florimond Manca
2f54548dad
Drop unecessary host="localhost" in https_server fixture to fix CI build (#1367) 2020-10-24 23:25:31 +02: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
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
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
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
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
d0427bead0
Clean up 'backend' fixture (#664)
* Clean up 'backend' fixture

* Add docstring to 'async_environment' fixture
2019-12-21 16:08:40 +01:00
Andrés Álvarez
e34df7a7a1 Rename concurrency directory to backends (#662)
Closes #659
2019-12-20 16:53:42 +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
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
toppk
f06ca87f97 Handle h11.Connection.next_event() RemoteProtocolError (#524)
raise (new) ConnectionClosed exception if this occurs when
socket is closed, otherwise reuse ProtocolError exception.

Add test case for ConnectionClosed behavior.

Resolves #96
2019-11-22 09:33:40 +01: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
Florimond Manca
08069e9368
Add DEBUG logs of HTTP requests (#502) 2019-11-06 22:56:25 +01:00
Florimond Manca
fc3df514e8 Don't check trio import in definition of backend fixture params (#447) 2019-10-05 19:12:06 -05:00
Florimond Manca
08355c62f5 Add trio concurrency backend (#276) 2019-09-21 11:10:20 -05:00
Seth Michael Larson
b0fa0859a8
Configure Proxy from Client (#353)
* Incorporate suggestions

* Start of proxy config

* Incorporate suggestions

* Add proxies to high-level API, docs

* Update client.py
2019-09-20 12:33:06 -05:00
Jamie Hewland
338a360785 Use a certificate issued from the trustme CA in tests (#357) 2019-09-18 18:59:27 -05:00
Roy Williams
05ac117679 Add .elapsed onto Response objects tracking how long a request took. (#351)
* Add `.elapsed` onto Response objects tracking how long a request took.

* Move elapsed timing from send methods into _get_response

* Address feedback

* Update tests/test_api.py

Co-Authored-By: Florimond Manca <florimond.manca@gmail.com>
2019-09-18 20:29:01 +02:00
Seth Michael Larson
57c27cac36
Implement HTTPProxy dispatcher (#259) 2019-09-15 10:47:35 -05:00
Dobrovolsky Bogdan
08edfac37d Add build_request to Client (#319)
* Update documentation

* Update documentation

* Update tests
Rename `_send` -> `_get_response`
Update documentation

* Code format with black

* Change documentation example to OPTIONS *

* Update documentation
Small code reformat

* `echo_headers` return json

* Simplify test

* Fix typo
2019-09-08 08:03:59 -05:00
Seth Michael Larson
b8c5e7a852 Add os.environ fixture (#308) 2019-09-02 23:12:52 +02:00
Bakhtiyor Ruziev
e34d280673 Add server.url property in tests (#300)
* Add server.url to test server

* Move a property to top of the class
2019-09-01 09:07:22 +02:00
Florimond Manca
994403bec9
Serve test server in thread (#292) 2019-08-29 23:17:14 +02:00
Florimond Manca
3674058ff7
Parametrize tests with concurrency backend (#273)
* Parametrize tests with concurrency backend

* Refactor server restart

* Add no-backend test
2019-08-25 20:25:18 +02: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
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
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
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
Yeray Diaz Diaz
b3af383923 Add test to https server
Add `https_server` test fixture
2019-05-13 20:33:16 +01:00
Matus Ferech
0629e55f98
Add status_code endpoint 2019-05-04 17:44:06 +02:00