Commit Graph

462 Commits

Author SHA1 Message Date
k3d3
9f7f712dde Add optional native-tls support, clear up warnings for flag configurations 2020-06-15 09:25:49 +02:00
Jacob Hoffman-Andrews
8a05241eac Move test server into its own function 2020-06-15 09:15:36 +02:00
Jacob Hoffman-Andrews
c1d7dbcfe9 Remove no-longer needed feature=tls 2020-06-15 09:15:36 +02:00
Jacob Hoffman-Andrews
64ef337c0b Fix connection_reuse test.
This test was making requests to a server on the Internet. That has the
potential to make the test flaky. Also, the test was relying on a
specific behavior from that server (timing out after 2s), which it no
longer exhibits.

This sets up a local test server that exhibits the specific properties
needed for this test.
2020-06-15 09:15:36 +02:00
Jacob Hoffman-Andrews
378ef57636 Fix findings from cargo clippy. 2020-06-15 09:11:43 +02:00
Jacob Hoffman-Andrews
b4c15eef2c Check for server closed connections.
This builds on 753d61b. Before we send a request, we can do a 1-byte
nonblocking peek on the connection. If the server has closed the
connection, this will give us an EOF, and we can take the connection out
of the pool before sending any request on it. This will reduce the
likelihood that we send a non-retryable POST on an already-closed
connection.

The server could still potentially close the connection between when we
make this check and when we finish sending the request, but this should
handle the majority of cases.
2020-06-15 09:11:25 +02:00
Martin Algesten
deb2002f6f port in host header. close #63 2020-06-12 22:00:30 +02:00
Martin Algesten
4196eeff40 remove curlies warnings 2020-06-12 21:03:49 +02:00
Martin Algesten
c5bc27260b code format 2020-05-23 09:29:57 +02:00
Martin Algesten
aa3e9b1ecf ensure overall connect timeout 2020-05-23 09:28:16 +02:00
David Wolinsky
1842a00da5 Try all sock_addrs before erroring on connect
If DNS resolves to multiple IPs but the service is only running on one
of them and it isn't teh first IP, a connection will fail.

This was detected via running vault that would only bind to IPv4 but
localhost was returning ::1 followed by 127.0.0.1.

After this fix, the service connects without problem.
2020-05-23 08:56:33 +02:00
Martin Algesten
c281307659 fix test warning 2020-05-20 21:25:47 +02:00
Martin Algesten
1e93f17a58 fix test problem 2020-05-20 21:22:35 +02:00
Rob Young
b61991d87e Fix a couple of feature flag uses
Wrap a json doc-test in cfg block to stop in failing when tests are
run with --no-default-features
2020-05-20 20:55:19 +02:00
Rob Young
2e3a75166d Allow TLS client config to be overridden
See: https://docs.rs/rustls/latest/rustls/struct.ClientConfig.html
2020-05-20 20:54:04 +02:00
Martin Algesten
49b6072921 cargo fmt 2020-05-06 13:48:52 +02:00
Paolo Barbolini
4e744f87c1 Keep the old Response::into_json around and call this Response::into_json_deserialize 2020-05-06 13:47:37 +02:00
Paolo Barbolini
0b69c595b6 Make Response::into_json deserialize into a serde DeserializeOwned
This removes the necessity to take the result of Response::into_json and
having to convert it into a struct by using serde_json::from_value

This adds no new dependencies since serde_json already depends on serde.
Users of ureq will have to include `serde_derive` either by importing it
directly or by using serde with the `derive` feature, unless they want to
manually implement `Deserialize` on their structs.
2020-05-06 13:47:37 +02:00
sklv
8f2d094cef SOCKS5: If host is domain use proxy for DNS. 2020-04-18 11:47:50 +02:00
Martin Algesten
a75d924f96 fix some warnings by moving imports around 2020-04-18 11:47:49 +02:00
bbx0
8c2d035809 Clean up dependencies 2020-04-18 11:47:49 +02:00
bbx0
55f42a614b Use &str instead of AsRef<str> to be consistent with the API 2020-04-18 11:47:49 +02:00
bbx0
3bedf9ab69 Add support for application/x-www-form-urlencoded 2020-04-18 11:47:49 +02:00
sklv
92b4e7ec2c Add TODO for supporting timeouts in Socks5Proxy. 2020-04-18 11:47:47 +02:00
sklv
a598b1091b Add comment explaining thread::spawn timeout. 2020-04-18 11:47:44 +02:00
sklv
b0898ae8fd Add comment explaining Proxy::new argument format. 2020-04-18 11:47:40 +02:00
sklv
9928559067 Make SOCKS5 connection respect timeout_connect. 2020-04-18 11:47:37 +02:00
sklv
05ce690ebd Add initial SOCKS5 support. 2020-04-18 11:47:30 +02:00
Koga Kazuo
e5fa36f98e Fix panic on invalid authority 2020-04-12 09:41:35 +02:00
Koga Kazuo
661853b95d Check status code that has no response body 2020-04-12 09:10:39 +02:00
Nicolas Viennot
31ae90e614 Use platform certificates when target "native-certs" is set
This is useful in Entreprise configurations.
2020-04-12 09:08:52 +02:00
Nicolas Viennot
652500f5a8 Improve chunked transfer upload performance
This implementation improves over chunked_transfer's Encoder + io::copy
with the following performance optimizations:

1) It avoid copying memory
2) chunked_transfer's Encoder issues 4 separate write() per chunk.
   This is costly overhead. Instead, we do a single write() per chunk

The measured benefit on a Linux machine is a 50% reduction in CPU usage
on a https connection.
2020-04-06 09:15:41 +02:00
rustysec
bb498ce699 added basic authentication method 2020-03-14 09:54:54 +01:00
rustysec
3b0df412ef initial proxy impl 2020-03-14 09:54:54 +01:00
Martin Algesten
2956683870 bump deps, fix clippy warnings 2020-03-14 09:54:54 +01:00
Rob Young
28bdb89175 Set a default content type for JSON requests
When sending a JSON request a Content-Type of application/json is
usually wanted. This is often set as a default for JSON methods by HTTP
clients so can be confusing when it is not set. However, we do not want
to prevent the user from setting their own Content-Type.
2020-02-06 07:57:00 +01:00
Razvan Rotari
09dabbdd49 Disable the native system timeout for socket 2020-01-17 23:15:26 +01:00
Martin Algesten
a4bae72fcb cargo fmt 2020-01-07 08:08:12 +01:00
Martin Algesten
63cfcfb23e doc format 2020-01-07 08:07:51 +01:00
Martin Algesten
4b9cfe2b67 fix clippy lints 2020-01-07 07:59:29 +01:00
Martin Algesten
a6f64188dc update serde_macros from origin 2020-01-07 07:59:29 +01:00
Tom Forbes
594340a096 Fix compilation errors with the cookies feature (#22)
* Fix compilation errors with the cookies feature
2019-10-30 11:51:06 +01:00
Martin Algesten
753d61b454 Retry some pooled connections failing when server closes. Close #10
This is not a perfect solution. It works as long as we are not sending
any body bytes. We discover the error first when attempting to read
the response status line. That means we discover the error after
sending body bytes. To be able to re-send the body, we would need to
introduce a buffer to be able to replay the body on the next
request. We don't currently do that.
2019-10-20 21:36:38 +02:00
Tom Forbes
da42f2ed8f Make cookies conditional 2019-10-20 20:17:35 +02:00
Martin Algesten
d9b8fef9a0 Code comment on *mut Stream effect on thread safety 2019-10-20 14:08:21 +02:00
Martin Algesten
acffc5fe13 Rename YoloRead -> ReclaimingRead
To better reflect why this is necessary. Also provide a doc comment why this is needed.
2019-10-20 12:31:55 +02:00
Martin Algesten
27be8117b8 Avoid tuple to describe response status line 2019-10-20 12:25:54 +02:00
Martin Algesten
d8f8220c3c clippy fix warning 2019-10-20 11:49:20 +02:00
Martin Algesten
acb40cc1a3 Fail if PoolKey::new() cant find port 2019-10-20 11:45:37 +02:00
Martin Algesten
f58ecac620 Simpler comparison for retaining x- headers 2019-10-20 11:19:16 +02:00