* 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>
* 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>
* 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>
* 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
* Use either brotli (recommended for CPython) or brotlicffi (Recommended for PyPy and others)
* Add comments in places where we switch behaviour depending on brotli/brotlicffi
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
Fix test_json_without_specified_encoding_*_error tests on big endian
platforms. The tests wrongly assume that data encoded as "utf-32-be"
can not be decoded as "utf-32". This is true on little endian platforms
but on big endian platforms "utf-32" is equivalent to "utf-32-be".
To avoid the problem, explicitly decode as "utf-32-le", as this should
trigger the expected exception independently of platform's endianness.
* Make Request and Response picklable
* fixup! Make Request and Response picklable
* Apply suggestions from code review
* Apply suggestions from code review
* Update tests/models/test_requests.py
Co-authored-by: Tom Christie <tom@tomchristie.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>
* 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>
* 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>
* 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>
* 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.
* 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.