Commit Graph

69 Commits

Author SHA1 Message Date
Tom Christie
631ba97635
Revert "Add content-length header for empty bytestream (#866)" (#898)
This reverts commit 939f3ce7ce.
2020-04-08 13:15:22 +01:00
Dima Boger
939f3ce7ce
Add content-length header for empty bytestream (#866)
Also, fixed related tests
2020-03-28 16:05:06 +01:00
Florimond Manca
82dc6f32f8 Switch to private module names (#785)
* Rename modules

* Update names in package

* Fix tests

* Review docs
2020-01-28 14:34:43 +00:00
Tom Christie
ee37a762ef
Reintroduce sync API. (#735)
* 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
2020-01-08 12:31:50 +00:00
Tom Christie
12dd157fea
Public Auth API (#732)
* Public Auth API

* Minor docs tweak

* Request.aread and Request.content

* Support requires_request_body

* Update tests/models/test_requests.py

Co-Authored-By: Florimond Manca <florimond.manca@gmail.com>

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
2020-01-07 13:20:23 +00:00
Andrés Álvarez
2b92a78c41 Drop Origin from public API (#688)
- 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>
2020-01-07 10:39:47 +00:00
Tom Christie
11e7604d1a
Sync streaming interface on responses (#695)
* Sync streaming interface on responses

* Fix test case

* Test coverage for sync response APIs

* Address review comments
2020-01-02 12:56:11 +00:00
Tom Christie
b8394f1e00
Bump coverage (#705)
* 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
2020-01-01 15:33:24 +00:00
Tom Christie
6a1ee0eb97
response.elapsed now reflects entire request/response time. (#692)
* 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.
2019-12-29 16:56:18 +00:00
Florimond Manca
f9d18a8758 Rename 'read/close' to 'aread/aclose' on Response (#674)
* Switch to aread/aclose on responses

* Linting

Co-authored-by: Tom Christie <tom@tomchristie.com>
2019-12-29 15:14:53 +00:00
Florimond Manca
56c8edaf66
Make 'request' non-optional on responses (#666)
* Make 'request' non-optional on Response

* Lint

* Remove remaining mention to null request
2019-12-21 15:38:25 +01:00
Tom Christie
cee1fccaca
Use Streams API for both requests and responses. (#648)
* Internal ContentStreams API
2019-12-20 16:05:04 +00:00
Tom Christie
74e5115b86
params argument on URL should merge, not replace. (#653) 2019-12-20 10:46:35 +00:00
Tom Christie
5ee512d803
Fix Host header and HSTS when the default port is explicitly included in URL (#649) 2019-12-20 10:25:42 +00:00
Tom Christie
8d4f182500
Added RequestContent (#636)
* Request Content

* Added RequestContent interface

* Docstrings on 'encode(data, files, json)'

* Update httpx/content.py

Co-Authored-By: Florimond Manca <florimond.manca@gmail.com>

* can_rewind -> can_replay
2019-12-18 10:51:34 +00:00
Tom Christie
ec40d04382
Add aiter methods on response (#610) 2019-12-06 15:20:09 +00:00
Tom Christie
d15dc0b1f8
Tighten up top-level API to only expose public API (#608)
* Tighten up top-level API to only expose public API

* Leave HTTPProxyMode for backwards compat, raising warnings.

* Add missing import
2019-12-06 15:20:01 +00:00
Tom Christie
fc95c7e71e
stream -> stream_bytes, raw -> stream_raw (#599) 2019-12-05 11:39:28 +00:00
Tom Christie
248aa580a1
Add Response.stream_lines (#575) 2019-11-30 18:02:46 +00:00
Tom Christie
fdaa01275a
Add Response.is_error (#574) 2019-11-30 17:43:48 +00:00
Casey
9df76ccfe9 Preserve list type query paramaters when merging QueryParams objects (#546) (#547) 2019-11-30 15:35:09 +00:00
Tom Christie
206c5372a6
Drop sync (#544)
Drop sync client
2019-11-27 10:43:42 +00:00
Florimond Manca
57ae7ea22b Allow lists in query params (#386) 2019-10-08 15:12:04 -05:00
Can Sarıgöl
e6da325e8b added authority copy feature in URL.copy_with (#436) 2019-10-04 09:17:25 +01:00
Seth Michael Larson
05f5dc26de
Get test suite back to ~100% line coverage (#406) 2019-09-29 13:58:22 -05:00
Florimond Manca
e62e5c3758
Add debug logs to ASGIDispatch (#371)
* Add debug logs to ASGIDispatch

* Tidy up ASGIDispatch

* Log entire scope and ASGI messages

* Obfuscate sensitive headers using common utility

* Update utils.py
2019-09-23 22:49:24 +02:00
Roy Williams
05ac117679 Add .elapsed onto Response objects tracking how long a request took. (#351)
* Add `.elapsed` onto Response objects tracking how long a request took.

* Move elapsed timing from send methods into _get_response

* Address feedback

* Update tests/test_api.py

Co-Authored-By: Florimond Manca <florimond.manca@gmail.com>
2019-09-18 20:29:01 +02:00
Seth Michael Larson
57c27cac36
Implement HTTPProxy dispatcher (#259) 2019-09-15 10:47:35 -05:00
Yeray Diaz Diaz
fa74aaa6db Add test for origin from URL string (#312) 2019-09-04 13:43:24 +02:00
euri10
cad9c03500 Added links property to BaseResponse (#211)
* Added docstring and better typing for parsed_header_links

* Added docstring and better typing for links property
Added tests for it too

* Added --diff to black check to see where CI fails
Relaxed travis build on master only

* Fixed black issue removing a \t

* Put noxfile and travis.yml as they were before
2019-08-16 09:07:52 -05:00
Seth Michael Larson
af907e85e1
Implement Response.stream_text() (#183) 2019-08-14 21:56:17 -05:00
Seth Michael Larson
80dc3e274e
Use nox for automation and CI (#128) 2019-08-13 08:39:35 -05:00
Seth Michael Larson
9142a893ff Move HSTS preload checking to client (#184) 2019-08-01 10:26:45 +01:00
Stephen Brown II
40849bffcb Update IDNA encoding to 2008 spec (#161)
* Update IDNA encoding to 2008 spec

* Add Unicode IDNA Compatibility Processing

* Parametrize idna test

* Use rfc3986 iri_reference for IDNA names

* Add test for IRI object

* Remove test_iri as this interface has been removed
2019-07-31 14:41:40 +01:00
Tom Christie
66754ad0c5
Tweak query param types (#175)
* Tweak query param types

* Handle primitive data types for queryparams

* QueryParam keys as str-only, not PrimitiveData
2019-07-31 00:27:20 +01:00
Seth Michael Larson
3ba2e8c328
Switch hosts on HSTS preload to HTTPS (#151) 2019-07-28 12:02:21 -05:00
Can Sarıgöl
7e9110b978 Add additional flake8 plugins (#157) 2019-07-28 11:40:05 -05:00
Tom Christie
00e4fdb05d Fix URL.join(...) (#144) 2019-07-25 17:01:03 -05:00
Stephen Brown II
8db36ed6a5 Allow string comparison for URL().__eq__ (#139) 2019-07-24 16:28:16 +01:00
Tom Christie
2d09d5b36c
Renaming -> httpx (#129)
* Renaming -> httpx

* Renaming to httpx
2019-07-19 15:15:16 +01:00
Yeray Diaz Diaz
5442006a41 Encoding detection in Response.json (#116)
* Use response text on `json`

Pass kwargs to the loads call

* Add failing test demonstrating corner case

* Copy `guess_json_utf` function from requests

* "Fix" type hinting and lint

* Actually add tests_utils.py
2019-07-11 17:14:58 +01:00
Tom Christie
fe1f9ed119
Minor tweaks in line with requests behavior (#110) 2019-07-03 10:33:38 +01:00
updatatoday
f9e3ad4c16 Fixed response repr. (#101)
* Fixed response repr.

* Fixed response repr tests.
2019-06-23 11:37:00 +01:00
Tom Christie
56a7943206
Int status codes (#92)
* Use plain int for response.status_code

* Linting
2019-06-17 16:53:39 +01:00
Tom Christie
c9747aa357
http3 (#86)
* Start fleshing out documentation

* Docs work

* http3

* Update docs

* Include lowercase status codes, for requests compat

* Updating docs

* Docs tweaks
2019-06-12 15:02:16 +01:00
Tom Christie
0cbf3c7581
Sync or Async dispatch (#83)
* Support thread-pooled dispatch

* Add ConcurrencyBackend.run

* Initial work towards support byte-iterators on sync request data

* Test case for byte iterator content

* byte iterator support for RequestData

* Add BaseResponse

* Bridge sync/async data in SyncResponse

* Add BaseClient

* SyncResponse -> Response

* Tweaking type annotation

* Distinct classes for Request, AsyncRequest

* Tweak is_streaming, content in BaseRequest

* Stream handling moves to client

* Handle mediating to AsyncResponse from a standard sync Dispatcher class

* Working on thread-pooled dispatcher

* Support threaded dispatch, inc. streaming requests/responses

* Increase test coverage

* Coverage and tweaks

* Include Accept and User-Agent headers by default
2019-06-10 12:26:03 +01:00
Tom Christie
76bc6c6dea
Drop Host header for HTTP/2 (#82) 2019-05-28 14:39:57 +01:00
Tom Christie
a284d0b2ea Tweak test naming 2019-05-17 13:49:24 +01:00
Tom Christie
bb703771b3 query_params -> params 2019-05-17 13:09:31 +01:00
Tom Christie
c6287ed782 query_params -> params 2019-05-17 13:06:26 +01:00