Commit Graph

57 Commits

Author SHA1 Message Date
lpraneis
ae2d521664 Add ability to specify multiple IP addresses for resolver overrides (#1622)
This change allows the `ClientBuilder::resolve_to_addrs` method to accept a
slice of `SocketAddr`s for overriding resolution for a single domain.
Allowing multiple IPs more accurately reflects behavior of `getaddrinfo`
and allows users to rely on hyper's happy eyeballs algorithm to connect
to a host that can accept traffic on IPv4 and IPv6.
2022-09-19 13:53:36 -07:00
Biagio Festa
8b37ae4b15 Support to rustls 0.20 (#1388) 2021-11-29 12:25:57 -08:00
Jonas Platte
4be5ec7ffd Replace use of assert_eq with assert
Reported by clippy.
2021-08-26 13:42:46 -07:00
Chris Campbell
8e5af459e5 Allow overriding of DNS resolution to specified IP addresses(#561) (#1277)
This change allows users to bypass the selected DNS resolver for
specific domains. The allows, for example, to make calls to a local TLS
server by rerouting a given domain to 127.0.0.1.

The approach I've taken for the design is to wrap the resolver in an
outer service. This leads to a fair amount of boilerplate code mainly to
be able to explain the typing to the compiler. The actual business logic
is very simple for the number of lines involved.

Closes #561
2021-06-16 14:41:08 -07:00
Mohamed Daahir
77ee0df7c5 Support Deflate decoding (#1250) 2021-04-22 10:35:29 -07:00
Markus Westerlind
2940740493 fix: Upgrade to http2 if the server reports that it supports it (#1166)
The test is disabled as the test server does not support TLS currently
but otherwise I'd expect it to pass (tested in another project).
2021-02-10 13:16:22 -08:00
Martin André
541d0c2aba Add https_only() for ClientBuilder (#1102)
Closes #980
2020-12-09 10:40:46 -08:00
est31
3ea9f92f24 Add rustls-tls-manual-roots feature to allow callers to specify roots
Now, callers have more control over the set of roots.

Note that, due to cargo unification, other dependencies in the
dependency tree might enable rustls-tls-webpki-roots
or rustls-tls.
This will affect connections initiated by code that explicitly
enabled rustls-tls-manual-roots.

So for now, the choice is done once per entire cargo
dependency graph. If people want more precise control
over things, they can add methods that allow controlling
this on a per-connection level. Even if such methods
are available, the *-manual-roots feature will still be
helpful with eliminating the webpki-roots dependency
for those cargo graphs where there is no unification.
2020-11-19 13:13:36 -08:00
stevelr
4fe07d81cf add ClientBuilder.default_headers() for wasm32 target (#1084) 2020-11-16 13:09:47 -08:00
fuyu
9e23103371 Fix detection of system proxy from Windows registry (#1005) 2020-08-19 11:38:21 -07:00
Sean McArthur
c916dc03cc Improve performance of Response::bytes() (#827) 2020-02-27 12:44:04 -08:00
Sean McArthur
2e06108f70 Require the native-tls feature to supply a preconfigured tls (#814) 2020-02-21 12:41:13 -08:00
Nick Lanham
9ab8ab945c add ability to create a client with own tls connector (#809) 2020-02-21 11:39:31 -08:00
EnokMan
f831d62da0 Brotli support (#791) 2020-02-19 12:49:11 -08:00
Sean McArthur
04980689ce Newest rustfmt changes 2020-02-06 10:17:40 -08:00
Sean McArthur
09e7fe62e3 Don't set User-Agent header by default (#751) 2019-12-23 12:48:11 -08:00
Gleb Pomykalov
0f32c4a01a Update to hyper 0.13 2019-12-10 16:24:05 -08:00
Constantin Nickel
24394364eb Make json an optional feature (default off) 2019-09-27 12:27:23 -07:00
Sean McArthur
f71227d968 Make gzip an optional feature (default off) 2019-09-23 15:46:25 -07:00
Sean McArthur
f4100e4148 Rewrite tests with a hyper server instead of raw TCP
This makes the tests much less brittle, by not depending on the exact
order of the HTTP headers, nor always requiring to check for every
single header.
2019-09-23 14:06:01 -07:00
Constantin Nickel
b1a90eb402 Prune the futures dependencies 2019-09-12 07:52:31 -07:00
Sean McArthur
5356776834 refine async API
- Converted `Response::text` and `Response::json` to `async fn`
- Added `Response::bytes` async fn as a counterpat to `text`.
- Added `Response::chunk` async fn to stream chunks of the response body.
- Added `From<Response> for Body` to allow piping a response as a request body.
- Removed `Decoder` from public API
- Removed body accessor methods from `Response`
- Removed `Chunk` type, replaced with `bytes::Bytes`.
- Removed public `impl Stream for Body`.
2019-09-10 14:06:09 -07:00
Sean McArthur
87a09322d6 Make the async Client default (#626)
The previously default Client is moved to `reqwest::blocking`, while the
async client becomes the main API.

Closes #622
2019-09-09 17:20:51 -07:00
Sean McArthur
ba7b2a754e refactor all to async/await (#617)
Co-authored-by: Danny Browning <danny.browning@protectwise.com>
Co-authored-by: Daniel Eades <danieleades@hotmail.com>
2019-09-06 17:22:56 -07:00
danieleades
cf8944a0f0 cargo fmt (#604)
Run rustfmt and setup CI to check for it.
2019-08-29 09:52:39 -07:00
WindSoilder
577d06c363 Add support for system/environment proxies (#547) 2019-07-01 16:27:58 -07:00
messense
564a08f230 Add Response::json() test cases 2019-06-26 11:11:07 -07:00
Jerome Gravel-Niquet
77434a29aa Fix overwriting of appended request headers (#493)
* don't overwrite appended user headers

* Fixes tests, all header ordering related

* does not need to clone default headers, added a test
2019-04-15 12:33:03 -07:00
Sean McArthur
7eae51f56e add form-urlencoded unit test 2019-02-13 11:46:12 -08:00
Sean McArthur
478ef9bf15 add Response::remote_addr() method
The new `remote_addr` method returns an `Option<SocketAddr>`, which is
`Some` if the underlying transport uses socket addresses.

Closes #373
2018-10-26 14:23:33 -07:00
Yash Srivastav
c417d6dab8 Upgrade hyper to 0.12
Closes #304
2018-07-05 10:03:31 -07:00
messense
0203fad886 Detect encoding in Response::text() (#256)
* Detect encoding and decode text response

Fixes #246

* Try to get encoding from Content-Type header

* Remove uchardet encoding detection for now

* Add non utf-8 test case for Response::text()

* Reduce copies
2018-02-15 11:01:57 -08:00
knight42
33c7ce4ce2 test: Response::text() 2017-10-27 14:58:16 +08:00
knight42
2bd558d8c7 test: add tests for setting default headers 2017-10-22 13:06:05 +08:00
knight42
c3d2a062fc Add test for Response::copy_to 2017-10-18 09:22:09 +08:00
Sean McArthur
779f8080ef change Builders to only error at the end
Closes #189
2017-08-31 18:10:45 -07:00
Tom Prince
855e6615eb Add error_for_status.
This makes it it easy to turn error responses into error
results.
2017-06-22 11:03:39 -07:00
Sean McArthur
665b4fe718 upgrade hyper to v0.11 2017-06-21 09:47:21 -07:00
James Kominick
df276b2913 fix client tests
- `Response` `status` now returns StatusCode by value
2017-06-08 22:24:50 -04:00
Sean McArthur
1eb05958e8 fix test that referenced HttpVersion 2017-06-01 17:12:39 -07:00
Sean McArthur
e176dcebca convert RequestBuilder to a &mut Self builder
Closes #108
2017-06-01 16:23:16 -07:00
Sean McArthur
8d784faa98 move all configuration from Client to ClientBuilder 2017-05-31 18:14:47 -07:00
Tom Prince
a2c24a4009 Some slightly less trivial rustfmt changes. 2017-05-31 14:50:32 -06:00
Tom Prince
4c60e6d35f Really trivial rustfmt changes. 2017-05-31 14:50:32 -06:00
Sean McArthur
a5fc8b6fe0 fix redirect tests that have an invalid header string 2017-05-31 11:34:00 -07:00
Sean McArthur
e00a64aa18 make sensitive header check include port
- adjusts to use &mut Headers
- add integration test
2017-05-18 10:58:41 -07:00
Sean McArthur
bafcd7ae6f add a referer() option to disable setting Referer header on redirects 2017-05-18 10:56:39 -07:00
Sean McArthur
d514d4e6e8 redirect and error reform
- `Error` has been made an opaque struct.
- `RedirectPolicy` now makes use of `RedirectAttempt` and `RedirectAction`.
2017-05-08 11:38:48 -07:00
Sean McArthur
3cc4d654a3 fix panic from Gzip reading an empty stream
Closes #82
2017-05-05 11:50:07 -07:00
Cyril Plisko
3c933a2947 Add test for response' final URL 2017-04-07 17:41:01 +03:00