Commit Graph

562 Commits

Author SHA1 Message Date
T-256
fc84f7f6eb
test same_origin via public api (#3062)
Co-authored-by: Tom Christie <tom@tomchristie.com>
2024-02-23 14:16:03 +00:00
T-256
e745060c75
test is_https_redirect via public api (#3064)
* test `is_https_redirect` via public api

* Update tests/test_utils.py
2024-02-23 14:11:43 +00:00
Tom Christie
cabd1c095e
Deprecate app=... in favor of explicit WSGITransport/ASGITransport. (#3050)
* Deprecate app=... in favour of explicit WSGITransport/ASGITransport

* Linting

* Linting

* Update WSGITransport and ASGITransport docs

* Deprecate app

* Drop deprecation tests

* Add CHANGELOG

* Deprecate 'app=...' shortcut, rather than removing it.

* Update CHANGELOG

* Fix test_asgi.test_deprecated_shortcut
2024-02-02 13:29:41 +00:00
Kar Petrosyan
371b6e946c
Use __future__.annotations (#3068)
* Switch to new typing style

* lint
2024-01-24 14:30:22 +00:00
T-256
4f6edf36e9
test parse_header_links via public api (#3061)
* test `parse_header_links` via public api

* add no-link test

* Update tests/test_utils.py

---------

Co-authored-by: Tom Christie <tom@tomchristie.com>
2024-01-16 10:25:02 +00:00
T-256
c7cd6aa5bd
test obfuscate_sensitive_headers via public api (#3063) 2024-01-16 09:53:23 +00:00
Tereza Tomcova
99cba6ac64
Fix RFC 2069 mode digest authentication (#3045)
* Fix RFC 2069 mode digest authentication

* Update CHANGELOG.md
2024-01-10 10:08:42 +00:00
Tom Christie
dd5304d3eb
Tidy up import (#3020)
Co-authored-by: Kar Petrosyan <92274156+karpetrosyan@users.noreply.github.com>
2023-12-28 13:10:37 +00:00
Tom Christie
a11fc3849b
Cleanup URL percent-encoding behavior. (#2990)
* Replace path_query_fragment encoding tests

* Remove replaced test cases

* Fix test case to use correct hex sequence for 'abc'

* Fix 'quote' behaviour so we don't double-escape.

* Add '/' to safe chars in query strings

* Update docstring

* Linting

* Update outdated comment.

* Revert unrelated change

---------

Co-authored-by: Kar Petrosyan <92274156+karpetrosyan@users.noreply.github.com>
2023-12-15 11:35:16 +00:00
Kar Petrosyan
3b9060ee11
Fix environment proxies (#2741)
* Add red test

* Make the test pass

* Lint

* chanelog

---------

Co-authored-by: Karen Petrosyan <92274156+karosis88@users.noreply.github.com>
Co-authored-by: Tom Christie <tom@tomchristie.com>
2023-12-14 14:04:04 +00:00
James Braza
2318fd822c
Enabling ruff C416 (#3001)
* Enabled C416 in ruff

* Ran ruff on all files

* Ran ruff format

* Update pyproject.toml

---------

Co-authored-by: Tom Christie <tom@tomchristie.com>
2023-12-13 11:30:39 +00:00
James Braza
1e11096473
Fixed iter_text adding an empty string (#2998) 2023-12-11 22:34:25 +00:00
Tom Christie
90538a3b46
Ensure that ASGI 'raw_path' does not include query component of URL. (#2999) 2023-12-11 15:45:20 +00:00
Kar Petrosyan
f8981f3d12
Add the 'proxy' parameter and deprecate 'proxies'. (#2879)
* Add the proxy parameter and deprecate proxies

* Make the Client.proxy and HTTPTransport.proxy types the same

* Update httpx/_transports/default.py

Co-authored-by: T-256 <132141463+T-256@users.noreply.github.com>

* Update httpx/_transports/default.py

Co-authored-by: T-256 <132141463+T-256@users.noreply.github.com>

* Drop unneeded noqa

* Changelog

* update documentation

* Allow None in mounts

* typos

* Update httpx/_types.py

* Changes proxies to proxy in CLI app

* Add proxy to request function

* Update CHANGELOG.md

Co-authored-by: Tom Christie <tom@tomchristie.com>

* Update docs/troubleshooting.md

Co-authored-by: Tom Christie <tom@tomchristie.com>

* Update docs/troubleshooting.md

Co-authored-by: Tom Christie <tom@tomchristie.com>

* Lint

---------

Co-authored-by: Tom Christie <tom@tomchristie.com>
Co-authored-by: T-256 <132141463+T-256@users.noreply.github.com>
2023-12-11 17:55:52 +04:00
Tom Christie
b471f01d66
Allow URLs where username or password contains unescaped '@'. (#2986)
* Add test cases for userinfo in URL

* Resolve failing test cases

* Update CHANGELOG.md

* Update CHANGELOG.md
2023-12-07 10:08:14 +00:00
Tom Christie
5b5f6d8e17
Moving test cases into 'test_url.py' (#2982)
* Moving test cases into 'test_url.py'

* Move test_url to test_basic_url

* Linting

* Move TypeError test case. Move basic httpx.URL cases.

* Linting

* Merge invalid URL cases

* Move percent encoding test cases

* Move remaining test cases

* Linting

* Add missing test cases
2023-12-05 15:36:05 +00:00
Tom Christie
724eced022
Reorganise tests in 'test_url.py' (#2981)
* Reorganise tests in 'test_url.py'

* Linting
2023-12-05 13:24:34 +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
Michał Górny
f653b2f0cf
Inline Brotli samples in tests (#2935)
Inline the compressed Brotli samples in tests to make them independent
of Brotli implementation.  This makes it possible to run the test suite
both against Brotli and brotlicffi.

Fixes #2906
2023-11-10 15:07:05 +00:00
Tom Christie
1d73150c1f
Cleanup response.json() method (#2911)
Co-authored-by: Kar Petrosyan <92274156+karpetrosyan@users.noreply.github.com>
2023-10-31 10:10:16 +00:00
robinaly
e63b6594f2
Fix encode host (#2886)
* Fix requiring dot literal rather than any character in IPv4

* Add check to prevent future errors
2023-10-10 12:03:47 +01:00
xzmeng
59df8190a4
Raise ValueError on Response.encoding being set after Response.text has been accessed (#2852)
* Raise ValueError on change encoding

* Always raise ValueError for simplicity

* update CHANGELOG.md
2023-09-19 08:54:32 +01:00
Y.D.X
e4241c6155
Drop private imports from test_proxies.py (#2850) 2023-09-16 21:58:56 +01:00
Musale Martin
88e8431437
Add cookies to the retried request when performing digest authentication. (#2846)
* Add cookies from the response to the retried request

* Conditionally add cookies from the response

* Fix failing auth module tests

* Fix linting error

* Add tests to check set cookies from server
2023-09-15 10:52:11 +01:00
Iurii Pliner
b40c04dfa6
Drop support for Python 3.7 (#2813)
* Drop Python 3.7 support

* Fix lint

* Changelog
2023-08-09 10:02:28 +01:00
Trim21
9415af643f
Make raise_for_status chainable (#2776)
* merge upstream

* lint

* Update test_async_client.py

* update docs

* add example

* Update docs/quickstart.md

Co-authored-by: Tom Christie <tom@tomchristie.com>

* Update CHANGELOG.md

Co-authored-by: Tom Christie <tom@tomchristie.com>

* Update docs/quickstart.md

Co-authored-by: Tom Christie <tom@tomchristie.com>

---------

Co-authored-by: Tom Christie <tom@tomchristie.com>
2023-08-01 10:22:58 +01:00
Zanie
18d7721c38
Use Mozilla documentation instead of httpstatuses.com for HTTP error reference (#2768) 2023-07-13 15:17:07 -05:00
Zanie Adkins
920333ea98
Always encode forward slashes as %2F in query parameters (#2723)
* Always encode forward slashes as `%2F` in query parameters

* Revert inclusion of "%"

This is expected to fail tests due to double escaping

* Update `urlencode`

---------

Co-authored-by: Tom Christie <tom@tomchristie.com>
2023-06-09 10:06:56 +01:00
Nik
a682f6f1c7
Fix exception suppression in asgi transport (#2669) 2023-05-21 01:17:23 +01:00
Peter Lazorchak
abb994c0c2
Ensure all WSGITransport environs have a SERVER_PROTOCOL (#2708) 2023-05-19 11:38:18 +01:00
Tom Christie
ee432c0d30
Fix for gen-delims escaping behaviour in path/query/fragment (#2701) 2023-05-09 14:20:12 +01:00
Tom Christie
26dc39213a
Additional context in InvalidURL exceptions (#2675) 2023-04-20 12:17:44 +01:00
Florimond Manca
cca62060cb
Drop private imports from test_decoders.py (#2570)
Co-authored-by: Tom Christie <tom@tomchristie.com>
2023-04-19 14:16:29 +01:00
Tom Christie
9ae170a936
Fix optional percent encoding behaviour. (#2671)
* Tests for failing optional percent encoding

* Linting

* Fix for optional percent escaping
2023-04-19 13:21:42 +01:00
Jiayun Shen
15d09a3bbc
fix: NO_PROXY should support IPv4, IPv6 and localhost (#2659)
* fix: NO_PROXY supports IPv4, IPv6 and localhost

* add more tests for test_get_environment_proxies

---------

Co-authored-by: Tom Christie <tom@tomchristie.com>
2023-04-19 13:14:37 +01:00
Marcelo Trylesinski
daec2bdcdb
Use ruff instead of flake8, autoflake and isort (#2648)
* Use ruff instead of flake8, autoflake and isort

* Update pyproject.toml
2023-04-05 12:37:10 +02:00
Tom Christie
f1157dbc41
Use standard logging style (#2547)
* Use standard logging style

* Add docs for logging

* Drop out-of-date HTTPX_LOG_LEVEL variable docs
2023-03-20 11:30:11 +00:00
Gianni Tedesco
85c5898d8e
Change LineDecoder to match stdlib splitlines, resulting in significant speed up (#2423)
* Replace quadratic algo in LineDecoder

Leading to enormous speedups when doing things such as
Response(...).iter_lines() as described on issue #2422

* Update httpx/_decoders.py

* Update _decoders.py

Handle text ending in `\r` more gracefully.
Return as much content as possible.

* Update test_decoders.py

* Update _decoders.py

* Update _decoders.py

* Update _decoders.py

* Update httpx/_decoders.py

Co-authored-by: cdeler <serj.krotov@gmail.com>

* Update _decoders.py

---------

Co-authored-by: Tom Christie <tom@tomchristie.com>
Co-authored-by: cdeler <serj.krotov@gmail.com>
2023-03-16 14:29:15 +00:00
Florimond Manca
a934c36a85
Drop private imports from test_urlparse.py (#2572)
* Drop private imports from test_urlparse.py

* Coverage

* Drop ._uri_reference
2023-02-15 14:43:19 +00: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
Florimond Manca
18e0ae45ca
Drop private imports from test_exported_members.py (#2573)
Co-authored-by: Tom Christie <tom@tomchristie.com>
2023-02-09 16:00:27 +00: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
78d381fc7d
Drop private imports from test_main.py (#2574)
Co-authored-by: Tom Christie <tom@tomchristie.com>
2023-02-09 15:50:09 +00:00
Florimond Manca
7488b15226
Drop private imports from test_exceptions.py (#2571) 2023-02-08 19:35:52 -05: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
Tom Christie
7947b56076
Drop private import of 'encode_request' in test_multipart (#2525) 2023-01-10 11:23:14 +00:00
Tom Christie
a6af45edac
Use '%20' for encoding spaces in query parameters. (#2543)
* Add failing test

* Fix failing test case

* Add urlencode

* Update comment
2023-01-10 11:16:09 +00:00
Tom Christie
57daabf673
Drop rfc3986 requirement. (#2252)
* Drop RawURL

* First pass at adding urlparse

* Update urlparse

* Add urlparse

* Add urlparse

* Unicode non-printables can be valid in IDNA hostnames

* Update _urlparse.py docstring

* Linting

* Trim away ununsed codepaths

* Tweaks for path validation depending on scheme and authority presence

* Minor cleanups

* Minor cleanups

* full_path -> raw_path, forr internal consistency

* Linting fixes

* Drop rfc3986 dependency

* Add test for #1833

* Linting

* Drop 'rfc3986' dependancy from README and docs homepage

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
2023-01-10 10:36:15 +00:00
Michael Adkins
bddd774ce0
Revert "Raise TypeError on invalid query params. (#2523)" (#2539)
This reverts commit 4cbf13ece2.
2023-01-04 09:23:32 +00:00