Commit Graph

511 Commits

Author SHA1 Message Date
Tom Christie
4cbf13ece2
Raise TypeError on invalid query params. (#2523)
* Raise TypeError on invalid query params

* Fix TypeError

* Update tests/models/test_queryparams.py

Co-authored-by: Michael Adkins <contact@zanie.dev>

* Linting

* Fix exception check

Co-authored-by: Michael Adkins <contact@zanie.dev>
2022-12-30 20:56:48 +00:00
Tom Christie
b82fbe2c13
Drop private import of 'format_form_param' from tests (#2500)
* Drop private import of 'format_form_param' from tests

* Drop unused code path
2022-12-12 16:31:29 +00:00
Tom Christie
b97c0594a5
Streaming multipart support (#2382)
* Streaming multipart support

* Update tests for streaming multipary
2022-12-12 16:14:56 +00:00
Tom Christie
af56476a8c
Drop unneccessary private import in tests (#2498) 2022-12-12 10:43:46 +00:00
Tom Christie
a8dd079be7
Raise TypeError if content is passed a 'dict' instance. (#2495) 2022-12-11 19:12:08 +00:00
Tom Christie
563a1031f5
Remove some private imports from test_decoders (#2496) 2022-12-06 18:22:04 +00:00
Tom Christie
71a1589928
Use httpx public API for 'test_content' tests (#2494) 2022-12-06 13:27:05 +00:00
Tom Christie
7985f685ca
Use consistent import style (#2493) 2022-12-06 11:58:30 +00:00
Demetri
40a0da093b
Add back in URL.raw with NamedTuple (#2481)
* add back in URL.raw with NamedTuple

* Update _urls.py

* Update _urls.py

Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-12-02 16:20:05 +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
884a69a902
Typing: enable strict_equality (#2480)
- ignore mypy when it comes to comparing an IntEnum member with an int
- Correct type hint for `test_wsgi_server_port`'s `expected_server_port`
  parameter.

Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-12-02 08:45:28 +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
rettier
8327e13454
reuse the digest auth state to avoid unnecessary requests (#2463)
* reuse the digest auth challenge to avoid sending twice as many requests

* fix for digest testcase

* ran testing/linting scripts

* codereview changes, removed tomchristie username from all authentication tests

Co-authored-by: Philipp Reitter <p.reitter@accessio.at>
Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-11-29 17:05:37 +00:00
Adrian Garcia Badaracco
69e13cbc39
Remove and dissallow unused type ignores (#2470)
* Remove and dissallow unused type ignores

* add pragmas

* fix ignore
2022-11-29 16:55:45 +00:00
Adrian Garcia Badaracco
1b4e7fbb48
Typing: always fill in generic type parameters (#2468)
* Typing: always fill in generic type parameters

Being explicit about the parameters helps find bugs and makes the library
easier to use for users.

- Tell mypy to disallow generics without parameter values
- Give all generic types parameters values

* fix things that aren't coming in from other commits

* lint

Co-authored-by: Martijn Pieters <mj@zopatista.com>
Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-11-29 16:36:03 +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
Tom Christie
883cf8ca6f
Drop multipart requirement from tests (#2456) 2022-11-21 10:29:31 +00:00
Tom Christie
8752e2672c
Drop .read/.aread from SyncByteStream/AsyncByteStream (#2407) 2022-11-07 14:01:29 +00:00
Vincent Fazio
1aea9539bb
Drop cgi module from test_multipart (#2424)
* Use multipart instead of cgi for multipart tests

The cgi module has been deprecated as of python 3.11.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>

* Update setup.cfg

All references to the cgi module have all been removed so there's no
longer a need to silence those deprecation warnings.

The deprecation warning for certifi is resolved as of version 2022.09.24.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-11-03 11:29:23 +00:00
Tom Christie
0ebe9259ac
Allow str content for multipart upload files (#2400) 2022-10-06 17:53:51 +01:00
Tom Christie
d5900cd40e
Fix empty query params (#2354)
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2022-09-02 14:24:45 +01:00
Adrian Garcia Badaracco
1526048c94
allow setting an explicit multipart boundary via headers (#2278) 2022-08-15 10:20:07 -05:00
Tom Christie
9baf3a6cd2
Drop RawURL (#2241) 2022-05-30 14:54:47 +01:00
Tom Christie
1c33a2854e
Make charset auto-detection optional. (#2165)
* Add Response(..., default_encoding=...)

* Add tests for Response(..., default_encoding=...)

* Add Client(..., default_encoding=...)

* Switch default encoding to 'utf-8' instead of 'autodetect'

* Make charset_normalizer an optional dependancy, not a mandatory one.

* Documentation

* Use callable for default_encoding

* Update tests for new charset autodetection API

* Update docs for new charset autodetection API

* Update requirements

* Drop charset_normalizer from requirements
2022-05-23 16:27:32 +01:00
Alan Li
e9b0c85dd4
Patch copy_with (#2185)
* Patch `copy_with`

* Add a new test for `copy_with`
2022-05-03 11:33:13 +01:00
Tom Christie
3350d7e683
Close responses when on cancellations occur during reading. (#2156)
* Test case for clean stream closing on cancellations

* Test case for clean stream closing on cancellations

* Linting on tests

* responses should close on any BaseException
2022-03-31 13:41:40 +01:00
waterfountain1996
4c307488cd
Suppress binary output on the command line (#2049) (#2076) 2022-02-09 15:40:39 +00:00
waterfountain1996
4401d55ecf
Preserve Authorization header on HTTPS redirect (#1850) (#2074)
* Preserve Authorization header on HTTPS redirect (#1850)

* Update httpx/_client.py

Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-02-09 11:18:21 +00:00
Tom Christie
420911bc69
Ensure that iter_bytes does not ever yield any zero-length chunks (#2068) 2022-02-07 09:19:26 +00:00
Tom Christie
0088253b32
Always rewind files on multipart uploads. (#2065)
* Test for multipart POST same file twice.

* Always rewind files on multipart uploads

* Linting
2022-02-04 14:48:57 +00:00
Adrian Garcia Badaracco
321d4aa509
Fix Headers.update to correctly handle repeated headers (#2038) 2022-01-21 08:35:10 -08:00
Tom Christie
8dc9b6bd59
SOCKS proxy support (#2034) 2022-01-19 14:58:19 +00:00
Tom Christie
7f0d43daad
Dont perform implicit close/warning on __del__ (#2026)
* Version 0.21.3

* Don't perform implict close on __del__
2022-01-13 10:37:37 +00:00
Adrian Garcia Badaracco
0f1ff50a1e
Allow custom headers in multipart/form-data requests (#1936)
* feat: allow passing multipart headers

* Add test for including content-type in headers

* lint

* override content_type with headers

* compare tuples based on length

* incorporate suggestion

* remove .title() on headers
2022-01-13 08:49:14 +00:00
Tom Christie
b7dc0c3df6
Fix for stream uploads that subclass SyncByteStream/AsyncByteStream (#2016) 2022-01-06 14:06:35 +00:00
Kian Meng, Ang
82ba15b521
Fix typos (#1968) 2021-12-14 15:04:01 +01:00
Tom Christie
6f5865f860
Read upload files using read(CHUNK_SIZE) rather than iter(). (#1948)
* Cap upload chunk sizes

* Use '.read' for file streaming, where possible

* Direct iteration should not apply chunk sizes
2021-11-22 13:15:39 +00:00
Tom Christie
61188feeae
Version 0.21 (#1935)
* Integrate with httpcore 0.14

* Fix pool timeout test

* Add request extensions to API

* Add certificate and connection info to client, using 'trace' extension

* Fix test_pool_timeout flakiness
2021-11-15 14:30:54 +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
Tom Christie
a761e17abc
is_informational / is_success / is_redirect / is_client_error / is_server_error (#1854) 2021-09-13 13:52:58 +01:00
Tom Christie
ff9813e84d
Transport API as plain request -> response method. (#1840)
* Responses as context managers

* timeout -> request.extensions

* Transport API -> request/response signature

* Fix top-level httpx.stream()

* Drop response context manager methods

* Simplify ASGI tests

* Black formatting
2021-09-13 13:34:46 +01:00
Tom Christie
47266d763b
Switch follow redirects default (#1808)
* Switch default on allow_redirects to False

* allow_redirects -> follow_redirects

* Update follow_redirects default in top-level API

* Update docs on follow_redirects
2021-09-13 13:21:22 +01:00
Adrian Garcia Badaracco
0b4a83257b
BUG: wsgi.error should be TextIO, not BytesIO in WSGI transport (#1828)
* wsgi.error should be StringIO, not BytesIO

Based on the documentation at https://modwsgi.readthedocs.io/en/master/user-guides/debugging-techniques.html#apache-error-log-files

* Default to sys.stderr and add test

* rename log_file param to wsgi_errors

Co-authored-by: Tom Christie <tom@tomchristie.com>
2021-09-07 15:44:35 +01:00
Stanis Trendelenburg
0d3fcc74a5
Close WSGI iterable when WSGIByteStream is closed (#1830)
* Make test fail when WSGI iterable is not closed

* Close WSGI iterable when WSGIByteStream is closed
2021-09-01 16:21:01 +01:00
Tom Christie
10b60d47c7
Fix iter_bytes with empty content (#1827) 2021-08-31 11:52:52 +01:00
Tom Christie
2d9c3580e0
Switch event hooks to also run on redirects. (#1806)
* Switch event hooks to also run on redirects

* Bump coverage

* Add pragma: no cover, because sometime ya just gotta be pragmatic

* Update docs with note about response.read()
2021-08-18 15:12:39 +01:00
Tom Christie
927c88d34f
Stricter enforcement of either 'with httpx.Client() as client' or 'client = httpx.Client()' lifespan styles. (#1800) 2021-08-13 15:17:15 +01:00
Antonio Larrosa
77193b2ab6
Add a network pytest mark for tests that use the network (#1669)
* Add a network pytest mark for tests that use the network

Sometimes it's useful to have the tests that use the network
marked so they can be skipped easily when we know the network
is not available.

This is useful for example on SUSE and openSUSE's build servers.
When building the httpx packages (actually, any package in the
distribution) the network is disabled so we can assure
reproducible builds (among other benefits). With this mark, it's
easier to skip tests that can not succeed.

* Add a better explanation for the network marker

Co-authored-by: Florimond Manca <15911462+florimondmanca@users.noreply.github.com>

Co-authored-by: Joe <nigelchiang@outlook.com>
Co-authored-by: Florimond Manca <15911462+florimondmanca@users.noreply.github.com>
Co-authored-by: Tom Christie <tom@tomchristie.com>
2021-08-13 14:13:43 +01:00