* Fix Content-Length for unicode file contents with multipart
* Handle bool and None cases for URLEncoded data
* Handle int, float, bool, and None for multipart or urlencoded data
* Update httpx/_utils.py
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
* 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>
* Maybe port is `None`
https://www.python.org/dev/peps/pep-3333/#environ-variables
> SERVER_NAME, SERVER_PORT
> When HTTP_HOST is not set, these variables can be combined to determine a default. See the URL Reconstruction section below for more detail. SERVER_NAME and SERVER_PORT are required strings and must never be empty.
* Add unit test
* Compute default port
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
* 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>
* 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>
* Allow tuple as input of query parameters.
In the documentation it is stated that params can be dict, string or two
tuples. This allows to used two tuples. Previously it was possible to
use only tuple inside a list.
* tests for two tuples
* use isinstance to check the type of query params
* change list|tuple to in Sequence
* update documentation
* fix typing
* Support iter_raw(chunk_size=...) and aiter_raw(chunk_size=...)
* Unit tests for ByteChunker
* Support iter_bytes(chunk_size=...)
* Add TextChunker
* Support iter_text(chunk_size=...)
* Fix merge with master
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
* 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
* Support header comparisons with dict or list.
* Add check for no headers item
* Fixup testcases affected by headers comparison using dict or list
* Update test_responses.py
Co-authored-by: Tom Christie <tom@tomchristie.com>
* url.userinfo should be URL encoded bytes
* Neater copy_with implementation
* Finesse API around URL properties and copy_with
* Docstring for URL, and drop url.authority
* Support url.copy_with(raw_path=...)
* Docstrings on URL methods
* Tweak docstring
* 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
* Internal refactoring to swap auth/redirects ordering
* Drop chardet for charset detection
* Drop chardet in favour of simpler charset autodetection
* Revert unintentionally included changes
* Update test case
* Refactor to prefer different decoding style
* Update text decoding docs/docstrings
* Resolve typo
* Update docs/quickstart.md
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
* 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>
* Made Client and AsyncClient checking for being closed in __del__ (#871)
* Changed the AsyncClient closing warning type from ResourceWarning (which is too quiet) to UserWarning (#871)
* Fixed tests and client's __exit__ and __aexit__ after the difficult merge (#871)
* Update test_proxies.py
* Update test_proxies.py
Co-authored-by: Tom Christie <tom@tomchristie.com>
* Use sync client in test cases
* Use plain client __init__ style in preference to context manager
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
* Prefer httpx.Client over httpx.AsyncClient in test cases, unless required.
* Prefer httpx.Client in test_headers
* Consistent httpx imports and httpx.Client usage
* Use 'import httpx' consistently in tests. Prefer httpx.Client.
* Version 0.14.0
* Update CHANGELOG
* Update CHANGELOG.md
Co-authored-by: Stephen Brown II <Stephen.Brown2@gmail.com>
* Update CHANGELOG
* max_keepalive_connections
* Add deprecation test
* Update CHANGELOG.md
* Undate dependency pin callout
* Update expected 1.0 release date
Co-authored-by: Stephen Brown II <Stephen.Brown2@gmail.com>
* Keep HTTPError as a base class for .request() and .raise_for_status()
* Updates for httpcore 0.10
* Update httpx/_exceptions.py
Co-authored-by: Stephen Brown II <Stephen.Brown2@gmail.com>
* Use httpcore.SimpleByteStream/httpcore.IteratorByteStream
* Use httpcore.PlainByteStream
* Merge master
* Update to httpcore 0.10.x
Co-authored-by: Stephen Brown II <Stephen.Brown2@gmail.com>
* URL.join(url=...), not URL.join(relative_url=...)
* Fix URL.join()
* Support no argument 'httpx.URL()' usage
* Support client.base_url as a property
* Resolve base_url joining behaviour
* Fix coverage
* Update _client.py
* #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>
* httpx.Timeout must include a default
* Tweak docstring
* Gentle deprecation for mandatory default on httpx.Timeout(...)
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
* Add internal URLMatcher class
* Use URLMatcher for proxy lookups in transport_for_url
* Docstring
* Pin pytest
* Add support for no-proxies configurations
* 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>
* Drop private Origin model
* Drop Origin from docs
* Update tests/test_utils.py
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
* Drop full_path test
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
* Fixes#1033 - Ensure that text that spans 3 invocations before newline is handled - don't clobber the buffer between invocations that haven't seen any lines.
This seems like a one character fix + the test.
* Update the tests.
* Undo formatting/indentation.
* Update long comment.
* Fix trailing cr line decoding
Co-authored-by: Sheridan C Rawlins <scr@verizonmedia.com>
Fixes#1033 - Ensure that text that spans 3 invocations before newline is handled - don't clobber the buffer between invocations that haven't seen any lines.
* Drop ASGIDispatch, WSGIDispatch, which has been replaced by ASGITransport, WSGITransport.
* Drop dispatch=... on client, which has been replaced by transport=...
* Drop soft_limit, hard_limit, which have been replaced by max_keepalive and max_connections.
* Drop Response.stream and Response.raw, which have been replaced by aiter_bytes and aiter_raw.
* Drop internal usage of as_network_error in favour of map_exceptions.
* 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
* 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
* 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>
* 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]'
* Deprecate Client arg 'dispatch' and use 'transport'
* Remove line in test from coverage
* Document custom transports
* _dispatch > _transports
Also rename *Dispatch classes to *Transport and added aliases
* Fix linting issues
* Missed one _transports import
* Promote URLLib3Transport to public API
* Remove duplicate arg doc
* Assert that urllib3 is imported to use URLLib3Transport
* `AsyncClient`, not asynchronous `Client`
* Add warning category to warn calls
* Update docs/advanced.md
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
* Add warn_deprecated utility function
* Amend docs references to dispatch
* Add concrete implementation example
* Clearer transport implementation description
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
* asgi: Wait for response to complete before sending disconnect message
* Dial back type checking + remove concurrency module
* Remove somewhat redundant comment
* 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
* Add reproducible test example for empty multipart
* Possible fix for empty combination of files/data
* Return bytestream with empty data/files
* Remove content-length in test
Co-authored-by: florimondmanca <florimond.manca@gmail.com>
* Add Auth.requires_response_body attribute
If set then responses are read by the client before being sent back into the auth flow
* Update tests and docs
* PR fixes
* Change example methods
* Detect auth in proxy URLs and create Proxy-authorization header
* Add credentials and SOCKS details to proxy documentation
* Use URL.copy_with to remove credentials from URL
* BaseClient and AsyncClient
* Introduce 'httpx.Client'
* Top level API -> sync
* Top level API -> sync
* Add WSGI support, drop deprecated imports
* Wire up timeouts to urllib3
* Wire up pool_limits
* Add urllib3 proxy support
* Pull #734 into sync Client
* Update AsyncClient docstring
* Simpler WSGI implementation
* Set body=None when no content
* Wrap urllib3 connection/read exceptions
- Drop the url.origin property.
- Drop Origin from the top-level export.
- Use origin = Origin(url) in our internal usage, rather than
url.origin.
Closes#656
Co-authored-by: Tom Christie <tom@tomchristie.com>
* 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>
* DigestAuth will raise exception if non-replayble request is passed #670
* Added new exception RequestBodyUnavailble exception to raise non replayable request error #670
* Changed RedirectBodyUnavailable exception to RequestBodyUnavailble to raise non-replayable exception #670
* fixed class declaration
* Added RequestBodyUnavailable exception. Imported it in module level
* Added RequestBodyUnavailable in the module list
* Code reformat
* Added Test to check if exception is raising if non-replayble request body is passed to DigestAuth #670
* Bump coverage
* Tests for iterative text decoding with 'aiter_text'
* nocover on xfail exception cases
* nocover API that is pending deprecation
* Tweak test to removed uncovered line
* Ingest request body in RedirectBodyUnavailable test case
* Changed behaviour of elapsed on response
* Fixed api docs for Response elapsed
* Minor tweaks to 'request.elapsed'
* Response instantiated with content should have elapsed==0
* Fix elapsed time on immediately closed responses.
* Drop per-request cert/verify/trust_env
* Remove cert/verify from the dispatcher API
* Apply lint
* Reintroduce cert/verify/trust_env on client methods, with errors
* Add .time() to backend
* Add connection timeouts
* Add test case for keep alive timeouts
* Update httpx/dispatch/connection_pool.py
Co-Authored-By: Florimond Manca <florimond.manca@gmail.com>
* Cleanups from review
* Use .expires_at, rather than .timeout_at
* 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