Commit Graph

91 Commits

Author SHA1 Message Date
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
Trim21
f115ce4e09
docs: upload progress (#2725)
* upload progress

* typo

* typo

* Update docs/advanced.md

* Update advanced.md

* Update docs/advanced.md

Co-authored-by: Kar Petrosyan <92274156+karosis88@users.noreply.github.com>

---------

Co-authored-by: Tom Christie <tom@tomchristie.com>
Co-authored-by: Kar Petrosyan <92274156+karosis88@users.noreply.github.com>
2023-07-13 15:55:41 +03: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
Florimond Manca
93de1980fa
Expand docs about retries (#2311)
Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-07-29 13:21:58 +01:00
Ofek Lev
9884965233
Update link to trustme (#2318) 2022-07-25 17:23:08 +08: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
Ninzero
2b26412868
Clarify custom auth (#2202) 2022-05-04 11:11:53 +02:00
Jorge
f7a024cee3
Corrected typo in advanced.md (#2155) 2022-03-30 16:58:00 +02:00
Ben Fasoli
6820b1d9c5
Fix invalid max_keepalive_connections argument name (#2094)
The argument to `httpx.Limits` is named `max_keepalive_connections` but is referenced as `max_keepalive` in the docs.
2022-02-25 14:10:35 +00:00
Udasi Tharani
2a08edc471
adding keepalive_expiry param to docs and docstring (#2090) 2022-02-22 10:40:14 +00:00
toppk
4f8068a7ad
update docstring/docs for transport using request/response models (#2070)
* update docstring/docs for transport based on pull #1840

* Update httpx/_transports/base.py

* lint'd

Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-02-08 14:58:08 +00:00
Tom Christie
8dc9b6bd59
SOCKS proxy support (#2034) 2022-01-19 14:58:19 +00:00
Kian Meng, Ang
82ba15b521
Fix typos (#1968) 2021-12-14 15:04:01 +01:00
Tyler Chamberlain
da8f959af0
Expand docs note for async custom handler responses (#1916)
* Expand note for async custom handler responses

Custom response handlers need to run `response.read()` before they can read the content of the response. However when using an AsyncClient this will produce an error of `RuntimeError: Attempted to call a sync iterator on an async stream.`. Took me some digging to figure out I just needed to use `response.aread()` here instead of `response.read()` so figured I would an MR with an expansion on the note for anyone else.
Thanks!

* Update advanced.md
2021-11-01 11:39:18 +00: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
Mei
604d09d7d7
Add netrc environment variable into the documentation (#1675)
* Adding netrc environment variable documentation

* Update docs/environment_variables.md

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

* Modifications about netrcfile environment variable

* Change uppercase "A" in netrcfile env variable into lowercase

* Added some words and a dot before "my_netrc" in the console example

* changed a typo "rather that" into "rather than" in advanced.md

* changed netrc environment variable in example part

* modified title for netrc environment variable part in doc

* Deleted the dot in title of netrc environment variable

Co-authored-by: Tom Christie <tom@tomchristie.com>
2021-06-16 07:04:47 +02:00
K900
776dbb578b
docs: slightly clarify event hooks (#1645)
* Be more specific about when the hooks are called
* Explicitly mention and demonstrate that hooks are allowed to modify requests

See https://github.com/encode/httpx/discussions/1637
2021-05-21 10:30:30 +01:00
Vytautas Liuolia
2e4b308d7a
Make the MockTransport example more robust/correct (#1621) 2021-05-02 20:04:12 +02:00
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
Hemanth kumar
535df6c998
Added docs for using client-side ssl certificates (#1570)
* Added docs for using client-side ssl certificates

* Update docs/advanced.md

Co-authored-by: Joe <nigelchiang@outlook.com>

* Update docs/advanced.md

Co-authored-by: Joe <nigelchiang@outlook.com>

* Update docs/advanced.md

* Update docs/advanced.md

* Update docs/advanced.md

Co-authored-by: Hemanth <hemanth@actionfi.com>
Co-authored-by: Tom Christie <tom@tomchristie.com>
Co-authored-by: Joe <nigelchiang@outlook.com>
2021-04-13 20:08:22 +08:00
Louis Maddox
68cf1ff88a
Fix typo to match library default (#1535)
Matches default given at https://github.com/encode/httpx/blob/master/httpx/_config.py#L359
2021-03-25 11:03:47 +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
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
Florimond Manca
25781a7625
Add troubleshooting guide, with initial proxies entries (#1435)
* Add troubleshooting guide, with initial proxies entries

* Drop unrelated issue
2020-12-29 13:40:53 +01:00
Florimond Manca
584a40513f
Tweak advanced timeouts docs (#1420) 2020-12-08 14:31:00 +01: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
Tom Christie
0af6d9a254
Use relative links for interlinking markdown files in docs (#1390) 2020-11-13 15:03:30 +00:00
emlazzarin
257b8fab6a
update arg name to max_keepalive_connections (#1309)
The old name `max_keepalive` was removed recently, so this updates the docs.
2020-09-23 10:42:21 +01:00
Stephen Brown II
a394df59da
Fix function name in event hooks docs (#1290) 2020-09-16 09:45:20 +08: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
59074c7bc0
Progress examples (#1272)
* Progress examples

* Update advanced.md

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-09-10 12:28:08 +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
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
Florimond Manca
8fa87650b2
Drop urllib3 in favor of public gist (#1182)
* Drop urllib3 in favor of public gist

* Drop urllib3 coverage omit

* Drop recommendation to use urllib3 transport during Requests migration

* Add urllib3-transport to 3p pkgs

* Drop urllib3 from dependencies list in README / docs home page

Co-authored-by: Tom Christie <tom@tomchristie.com>
2020-09-04 22:56:36 +02:00
Joe
84ca2010e1
Add proxies parameter to top-level API functions (#1198)
* Add `proxies` parameter to top-level API functions

* Fix typo
2020-08-20 15:55:35 +08:00
Hugo van Kemenade
d10b7cdc51
Use pycon for Python console code blocks (#1187)
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-08-18 15:17:44 +02:00
Florimond Manca
34ba0e14b0
Document Unix Domain Socket usage (#1186) 2020-08-17 14:49:09 +02:00
Tom Christie
477824aeaa
Advanced transport docs (#1165)
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-08-11 17:05:44 +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
0fb28e8cab
Refine docs phrasing on proxy routing (#1124) 2020-08-03 10:29:03 +01:00
Florimond Manca
70cdd95006
Revamp proxies documentation (#1123) 2020-08-02 14:02:43 +02: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
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
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
0f7d644b8d
Add note on data fields in multipart form encoding (#1022)
* Add note on data fields in multipart form encoding

* Fix message
2020-06-15 20:40:17 +02:00
Florimond Manca
a58be59adb
Add note on streaming uploads (#973) 2020-05-21 16:13:16 +02:00
Tom Christie
99a5c78bbb
Update dependencies in docs (#969)
* Update dependencies in docs

* Update README.md

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

* Update docs/index.md

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

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-05-21 13:43:34 +01: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