Commit Graph

712 Commits

Author SHA1 Message Date
messense
329e1f4ada Switch to rustls-webpki 2023-05-12 20:25:29 +02:00
Devrim Şahin
d2a1d30b20 fix clippy finding 2023-05-12 20:13:14 +02:00
Devrim Şahin
cd70959360 remove the Option from local_addr, replace unwrap() 2023-05-12 20:13:14 +02:00
Devrim Şahin
c305b915f8 fix flaky test(s) 2023-05-12 20:13:14 +02:00
Devrim Şahin
11a8eb470c make local_addr syscall unconditional 2023-05-12 20:13:14 +02:00
Martin Algesten
7e32dbaaaf Read local_addr from socket 2023-05-12 20:13:14 +02:00
Devrim Şahin
bfb0ef16e1 expose local_addr() from Response 2023-05-12 20:13:14 +02:00
stelofan
ec663fad45 fix cannot use http_proxy connect non-standard http ports 2023-04-16 09:19:27 +02:00
Jacob Hoffman-Andrews
2e7bcf255a Update rustls to 0.21 (#601)
This introduces support for IP address certificates!
2023-03-31 14:29:53 -07:00
Jacob Hoffman-Andrews
ad1ff0c37f http_interop: fix tests (#606) 2023-03-30 21:02:53 -07:00
Jacob Hoffman-Andrews
ce4b9f28e2 lock serde_json below 1.0.94 (#603)
This avoids a bug in more recent version that prevents us from
downcasting errors to see if they are TimedOut errors.
2023-03-30 11:00:13 -07:00
Lukas Wagner
20a9ae7977 Proxy: Only use HTTP CONNECT for HTTPS requests
Previously, `ureq` used `HTTP CONNECT` for *all* requests, including
plain-text HTTP requests. However, some proxy servers like Squid
only allow tunneling via the `HTTP CONNECT` method on port 443 - since
it is usually only used to proxy HTTPS requests. As a result,
it was not possible to use `ureq` with a Squid server in its default configuration.

With the changes from this commit, ureq will interact with HTTP proxies
in a more standard-conforming way, where `CONNECT` is only used for
HTTPS requests. HTTP request paths are transformed in such a way that they
comply with RFC 7230 [1].

Tested against Squid 4.13 in standard configuration, with and without basic authentication,
for HTTP and HTTPS requests.

[1] https://www.rfc-editor.org/rfc/rfc7230#section-5.3.2
2023-03-16 11:59:23 +01:00
Kade Robertson
bdcee72c53 docs: update README with http-interop feature 2023-03-15 03:54:13 +01:00
Kade Robertson
f4314e53ac docs: cover usage + doctests 2023-03-15 03:54:13 +01:00
Kade Robertson
6385b72d31 test: additional basic coverage for conversions 2023-03-15 03:54:13 +01:00
Kade Robertson
f077a4012c ci: fix http feature name 2023-03-15 03:54:13 +01:00
Kade Robertson
06db500ec4 refactor: keep http-related code together 2023-03-15 03:54:13 +01:00
Kade Robertson
7dcd60cbaf refactor: rename feature to http-interop 2023-03-15 03:54:13 +01:00
Kade Robertson
dff55fda4e feat: bidirectional http request conversion 2023-03-15 03:54:13 +01:00
Kade Robertson
f395a726e3 feat: bidrectional http response conversion 2023-03-15 03:54:13 +01:00
SwayStar123
efdd55421f Update request.rs 2023-03-13 16:35:36 +01:00
Fabian Grünbichler
2b86691a81 proxy: set proper user agent
instead of hard-coding "something/1.0.0".

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-03-13 16:28:57 +01:00
Martin Algesten
b66e558027 Fix clippy 2023-03-13 16:27:38 +01:00
Martin Algesten
05b9a82a38 Clippy fix 2023-01-31 08:52:47 +01:00
Martin Algesten
abda74c4d8 Upgrade deps 2023-01-31 08:52:47 +01:00
Jacob Hoffman-Andrews
34b239b388 Remove note about 2.0.0 being recent (#584) 2023-01-17 16:17:11 -08:00
Jacob Hoffman-Andrews
498e19943f Allow non-empty connection pools to be dropped (#583)
This breaks a reference cycle between PoolReturner and Agent that was
causing Agents (and their contained ConnectionPool) to never be dropped
so long as there was any stream in the ConnectionPool. This cause
sockets to leak over time, particularly when the convenience functions
ureq::get(), ureq::post(), etc were used, since those functions create
a new Agent each time.
2023-01-16 08:33:56 -08:00
Nathan Henrie
33fb553a28 Remove references to serde_derive (#581) 2023-01-09 14:46:00 -08:00
Jacob Hoffman-Andrews
032bfb4b27 gzip: examine Content-Length header before removing (#578)
Fixes #575.
2023-01-02 20:02:37 -08:00
Jacob Hoffman-Andrews
78ec3a4d75 Update CHANGELOG for 2.6.0 (#572) 2022-12-30 21:56:23 -08:00
Jacob Hoffman-Andrews
a8ca1ec085 Fix clippy 2022-12-09 17:03:35 +01:00
Jacob Hoffman-Andrews
6bef9daa8e Switch ureq to used forked chunked_transfer. 2022-12-09 17:03:35 +01:00
Jacob Hoffman-Andrews
43a12cdf51 Modify chunked crate for ureq use. 2022-12-09 17:03:35 +01:00
Jacob Hoffman-Andrews
fe3f1d550b Fork chunked_transfer crate 2022-12-09 17:03:35 +01:00
Jacob Hoffman-Andrews
9083d692f8 Redesign pooling mechanic (#565)
Introduce PoolReturner, a handle on an agent and a PoolKey that is
capable of returning a Stream to a Pool. Make Streams keep track of
their own PoolReturner, instead of having PoolReturnRead keep track of
that information.

For the LimitedRead code path, get rid of PoolReturnRead. Instead,
LimitedRead is responsible for returning its Stream to the Pool after
its second-to-last read. In other words, LimitedRead will return the
stream if the next read is guaranteed to return Ok(0).

Constructing a LimitedRead of size 0 is always wrong, because we could
always just return the stream immediately. Change the size argument to
NonZeroUsize to enforce that.

Remove the Done trait, which was only used for LimitedRead. It was used
to try and make sure we returned the stream to the pool on exact reads,
but was not reliable.

This does not yet move the ChunkDecoder code path away from
PoolReturnRead. That requires a little more work.

Part 1 of #559.  Fixes #555.
2022-12-03 23:42:58 -08:00
Jacob Hoffman-Andrews
d8225b22ed Split response body type into own function (#566)
This allows removing the hack where we create a Response with an empty `reader`,
then immediately mutate it to set the real reader. It also happens to allow us
to get rid of 3 fields of Response that were only used to pass information to
`stream_to_reader`.

I've tried to keep the structure and logic of the body calculation as close to
the same as possible, for ease of review and to avoid introducing bugs. I think
there are some followup fixes we can make to the logic, which will be made
easier by having it in a self contained function.
2022-12-03 10:22:53 -08:00
Jacob Hoffman-Andrews
cf687381bd Don't panic when rustls-native-certs errors (#564)
Fixes #563
2022-11-30 22:12:48 -08:00
Martin Algesten
f36c140315 Add gzip and brotli to CI test matrix 2022-11-26 11:46:00 +01:00
Martin Algesten
8e8b1abd53 Upgrade deps 2022-11-26 11:46:00 +01:00
zu1k
614d1dd7bc Make query_pairs more generic
Signed-off-by: zu1k <i@zu1k.com>
2022-11-26 11:09:33 +01:00
zu1k
78998dd032 feat: Set multi query parameters
Signed-off-by: zu1k <i@zu1k.com>
2022-11-26 11:09:33 +01:00
Jacob Hoffman-Andrews
dc7a8c3ebe Config-gate gzip test 2022-11-26 01:44:08 -08:00
Jacob Hoffman-Andrews
3745b028c6 Switch to MultiGzDecoder
This is more correct, since all gzip streams can consist of multiple members. It
has the happy side effect that it causes gzipped responses to reliably return
their streams to the pool.
2022-11-26 01:44:08 -08:00
Martin Algesten
5d9e89917c Test case showing gzip chunk not pooling 2022-11-26 01:44:08 -08:00
Jacob Hoffman-Andrews
a2836c49a7 Fix new clippy lints (#561) 2022-11-26 10:28:36 +01:00
Wolf Thomsen
28d667ade9 add badges to crates.io and docs.rs to README.md (#554) 2022-11-12 21:31:58 +01:00
Max von Forell
855f20e662 Add Response::remote_addr() (#489)
Fixes #488.
2022-10-03 13:29:21 -07:00
Martin Algesten
b0796c18f3 Make build work (#546)
The mbedtls example has caused problem in the main build a number of
times. By making it a standalone `cargo new --bin`, we can keep it in
the source tree as a good example but avoid having it break the main
build.

Also, fix some clippy lints.
2022-09-29 08:29:32 -07:00
Michael Schubart
a367a82317 Fix mistake in API docs 2022-08-28 12:09:17 +02:00
Martin Algesten
134d82ecf4 debug! log method of body response 2022-07-10 11:55:57 +02:00