Commit Graph
100 Commits
Author SHA1 Message Date
Martin Algesten c24b250c80 Implement std::error::Error for error::Transport (#299)
Close #294
2021-01-09 09:56:20 -08:00
Martin Algesten 6da035b669 Update CHANGELOG.md
Change 2.0.0-rc2 => 2.0.0
2021-01-03 21:22:40 +01:00
Martin Algesten 8f9f3e5827 Fix main lib.rs and README.md example (#284)
Small fixes to just ensure lib.rs and README.md are run via cargo readme.
2021-01-03 10:38:10 -08:00
Martin Algesten 1f0d84279a Document simplest error example 2020-12-27 23:47:43 +01:00
Martin Algesten 5aff777f1f Refactor Display for Transport 2020-12-05 20:00:47 +01:00
Martin Algesten b91d196fbc error::Transport part of public API 2020-12-05 20:00:47 +01:00
Martin Algesten f652a9e449 rename error_for_status -> error_on_non_2xx 2020-11-15 21:13:45 +01:00
Martin Algesten d4af920b53 Fix body send doc tests 2020-11-15 21:10:19 +01:00
Martin Algesten b66e618198 Gate entire mod cookies on "cookies" feature 2020-11-08 11:31:49 +01:00
Martin Algesten d0789ae8e9 Rename AgentBuilder set_tls_config -> tls_config
For consistency. We don't use set_xxx on the builder.
2020-11-08 11:31:49 +01:00
Martin Algesten a8ee8ab75e Provide AgentBuilder::cookie_store setter 2020-11-08 11:31:49 +01:00
Martin Algesten c2bbd57acc Agent::cookie_store to persist cookies 2020-11-08 11:31:49 +01:00
Martin Algesten 18201a08c5 Remove Agent::set_cookie
Preloading an agent with cookies can be done by providing a prepared
cookie store using `AgentBuilder`. At this point, we don't want direct
state mutation on the `Agent`, so this fn goes away.

Context:
https://github.com/algesten/ureq/issues/203#issuecomment-716385310
2020-11-08 11:31:49 +01:00
Martin Algesten e37acc85b2 Remove AgentBuilder::set headers
The headers are not scoped by host, which means using them for
something like `Authorization` would effectively "leak" to all
requests using the agent.

Context:
https://github.com/algesten/ureq/issues/203#issuecomment-716385310
2020-11-08 11:31:49 +01:00
Martin Algesten 1369c32351 API changes for 2.0
* Remove Request::build
* All mutations on Request follow builder pattern

The previous `build()` on request was necessary because mutating
functions did not follow a proper builder pattern (taking `&mut self`
instead of `mut self`). With a proper builder pattern, the need for
`.build()` goes away.

* All Request body and call methods consume self

Anything which "executes" the request will now consume the `Request`
to produce a `Result<Response>`.

* Move all config from request to agent builder

Timeouts, redirect config, proxy settings and TLS config are now on
`AgentBuilder`.

* Rename max_pool_connections -> max_idle_connections
* Rename max_pool_connections_per_host ->  max_idle_connections_per_host

Consistent internal and external naming.

* Introduce new AgentConfig for static config created by builder.

`Agent` can be seen as having two parts. Static config and a mutable
shared state between all states. The static config goes into
`AgentConfig` and the mutable shared state into `AgentState`.

* Replace all use of `Default` for `new`.

Deriving or implementing `Default` makes for a secondary instantiation
API.  It is useful in some cases, but gets very confusing when there
is both `new` _and_ a `Default`. It's especially devious for derived
values where a reasonable default is not `0`, `false` or `None`.

* Remove feature native_tls, we want only native rustls.

This feature made for very clunky handling throughout the code. From a
security point of view, it's better to stick with one single TLS API.
Rustls recently got an official audit (very positive).

https://github.com/ctz/rustls/tree/master/audit

Rustls deliberately omits support for older, insecure TLS such as TLS
1.1 or RC4. This might be a problem for a user of ureq, but on balance
not considered important enough to keep native_tls.

* Remove auth and support for basic auth.

The API just wasn't enough. A future reintroduction should at least
also provide a `Bearer` mechanism and possibly more.

* Rename jar -> cookie_store
* Rename jar -> cookie_tin

Just make some field names sync up with the type.

* Drop "cookies" as default feature

The need for handling cookies is probably rare, let's not enable it by
default.

* Change all feature checks for "cookie" to "cookies"

The outward facing feature is "cookies" and I think it's better form
that the code uses the official feature name instead of the optional
library "cookies".

* Keep `set` on Agent level as well as AgentBuilder.

The idea is that an auth exchange might result in a header that need
to be set _after_ the agent has been built.
2020-10-25 11:47:38 +01:00
Martin Algesten 6e997909bf Document release process 2020-10-19 01:18:56 +02:00
Martin Algesten e763446d72 1.5.1 2020-10-06 10:06:36 +02:00
Martin Algesten 95cbb15a68 Changelog for 1.5.1 2020-10-06 10:05:48 +02:00
Martin Algesten 0bf981031b Replace lazy_static! with once_cell Lazy (#176)
Modern rust code bases prefer once_cell::sync::Lazy over the older
macro based lazy_static.
2020-10-04 09:35:31 -07:00
Martin Algesten 573b175cf7 1.5.0 2020-09-29 11:12:00 +02:00
Martin Algesten 0346794e87 Fix bug in force-unwrapping when resetting timers
When running tests locally, this error can surface.

```
---- test::agent_test::custom_resolver stdout ----
thread 'test::agent_test::custom_resolver' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 22, kind: InvalidInput, message: "Invalid argument" }', src/stream.rs:60:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

The problem is that setting the timeouts might fail, and this is done
in a From trait where there is not possibility to "bubble" the
io::Error.

```
socket.set_read_timeout(None).unwrap();
socket.set_write_timeout(None).unwrap();
```

This commit moves the resetting of timers to an explicit `Stream::reset()` fn
that must be called every time we're unwrapping the inner stream.
2020-09-29 11:10:16 +02:00
Martin Algesten 155edeef19 cargo fmt (#151) 2020-09-19 00:28:39 -07:00
Martin Algesten 05ffe53e4c CI: error on dead/unused code for features (#146)
By using `RUSTFLAGS="-D dead_code -D unused-variables -D unused"`, we tell
the compiler to upgrade warnings for unused code to errors. This combined
with a more elaborate test matrix means we can have the CI catch feature
flag combos that cause warnings.
2020-09-18 13:55:23 -07:00
Martin Algesten b8b67a41a9 1.4.1 2020-09-13 21:46:49 +02:00
Martin Algesten 64ab65ba35 CHANGELOG 1.4.1 2020-09-13 21:46:49 +02:00
Martin Algesten 50c19c5484 Read buffer to avoid byte-by-byte syscalls (#141)
Fixes #140
2020-09-12 18:27:15 -07:00
Martin Algesten 960c0ff43b 1.4.0 2020-08-14 23:08:08 +02:00
Martin Algesten 29782bc97d Add CHANGELOG.md 2020-08-14 23:08:08 +02:00
Martin Algesten a198ba0a65 Test case for preserving io::Error timed out 2020-08-07 21:51:35 +02:00
Martin Algesten 4bc6f79847 cargo fmt 2020-08-07 21:51:35 +02:00
Martin Algesten 6614856163 Make Response::to_json preserve io::Error of ErrorKind::TimedOut
Close #119
2020-08-07 21:51:35 +02:00
Martin Algesten db4cc90956 Normalize timeout ErrorKind::WouldBlock to be TimedOut (#131)
`set_read_timeout` and `set_write_timeout` can cause `ErrorKind::WouldBlock` on unix-y platforms.

This PR normalizes those cases to `ErrorKind::TimedOut`. This will make it simpler higher up in the
stack to deal with timeouts.
2020-08-07 10:06:56 -07:00
Martin Algesten 4e1e3d1ad4 Make features to use for docs.rs build explicit (#90)
Since tls and native-tls are mutually exclusive, we can't use
all-features anymore. Instead we enumerate the features needed to
build the docs for docs.rs.
2020-06-24 09:37:15 -07:00
Martin Algesten 6bb838f205 Fix building with socks-proxy feature (#91)
This PR corrects a variable name and type, and ensures we
test the socks-proxy feature as part of the test matrix.
2020-06-24 09:36:08 -07:00
Martin Algesten 787b11b1e4 1.2.0 2020-06-15 09:38:50 +02:00
Martin Algesten 89593d28b3 comment about native-tls 2020-06-15 09:37:10 +02:00
Martin Algesten 7a73fa1871 cargo fmt 2020-06-15 09:33:08 +02:00
Martin Algesten 0b6323df44 1.1.2 2020-06-12 22:01:02 +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
Martin Algesten f03995a72f 1.1.1 2020-05-23 08:57:50 +02:00
Martin Algesten 8c1068d40d 1.1.0 2020-05-20 21:29:20 +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
Martin Algesten bbfd125025 1.0.0 2020-05-06 13:57:01 +02:00
Martin Algesten 49b6072921 cargo fmt 2020-05-06 13:48:52 +02:00
Martin Algesten a75d924f96 fix some warnings by moving imports around 2020-04-18 11:47:49 +02:00
Martin Algesten 12110bd6a5 0.12.1 2020-04-12 09:46:01 +02:00
Martin Algesten b62db974f0 0.12.0 2020-03-14 10:42:11 +01:00
Martin Algesten 2956683870 bump deps, fix clippy warnings 2020-03-14 09:54:54 +01:00
Martin Algesten f61ef77f7f 0.11.4 2020-02-06 08:19:12 +01:00
Martin Algesten 662d001c79 update readme about ureqs future 2020-02-06 08:18:45 +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
Martin Algesten 9afbb834af Correctness doc comment 2019-10-20 19:32:18 +02:00
Martin Algesten 3642e27a26 CI badge 2019-10-20 19:31:48 +02:00
Martin Algesten e0da4bc2d6 nop 2019-10-20 19:16:06 +02:00
Martin Algesten d9b8fef9a0 Code comment on *mut Stream effect on thread safety 2019-10-20 14:08:21 +02:00
Martin Algesten 8871183df0 0.11.2 2019-10-20 13:32:09 +02:00
Martin Algesten 4c490ed7f1 bump deps 2019-10-20 13:31:30 +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
Martin Algesten 999653e7f3 handle header with spaces before value 2019-10-20 10:58:16 +02:00
Martin Algesten e936d5ea74 cargo fmt 2019-10-20 10:41:35 +02:00
Martin Algesten ed999b579d Removing AsciiString dep and one unsafe
This library is not about enforcing standards, so the internal use of
AsciiString for headers and status lines is not necessary.
2019-10-20 10:40:30 +02:00
Martin Algesten ee40b2cff0 Clarify license. Close #19 2019-10-20 10:26:05 +02:00
Martin Algesten c307da1fc0 qstring 0.7 2019-09-15 10:43:49 +02:00
Martin Algesten 9913f22229 0.11.1 2019-09-14 08:42:54 +02:00
Martin Algesten c2bb5a9592 fix test --no-default-features 2019-09-14 08:41:59 +02:00
Martin Algesten 90e3e7ab1a 0.11.0 2019-06-21 15:55:32 +02:00
Martin Algesten fef05fd5c9 send_bytes 2019-06-21 15:53:45 +02:00
Martin Algesten 9d069b60b4 fix tests 2019-06-21 15:53:23 +02:00
Martin Algesten 32279c84e0 impl std::error::Error for Error close #6 2019-06-21 15:14:58 +02:00
Martin Algesten 41b21d37e4 fix clippy warnings 2019-06-21 15:09:36 +02:00
Martin Algesten 819a9d1e0c 0.10.0 2019-05-28 12:25:56 +02:00
Martin Algesten bc08eb77fe Merge pull request #5 from FauxFaux/bump-include
Use pub(crate), not include!(), to access private fields
2019-05-28 12:21:52 +02:00
Martin Algesten 3aee135429 0.9.1 2019-03-30 11:35:39 +01:00
Martin Algesten a89150eee7 fix warning in --no-default-features 2019-03-30 11:34:35 +01:00
Martin Algesten 8eb59acc66 update deps 2019-03-30 11:32:51 +01:00
Martin Algesten d4d68ae585 fix parse error when no status text. close #4 2019-03-30 11:29:53 +01:00
Martin Algesten 889988b4a3 bump version 2019-02-03 12:06:29 +05:30
Martin Algesten 22e83fc31c fixes for no-default-features 2019-02-03 12:05:27 +05:30
Martin Algesten aa2508bfcc updated deps 2019-02-03 11:53:35 +05:30
Martin Algesten 141668acba list all header names in request and response 2019-02-03 11:52:05 +05:30
Martin Algesten 4c9da1dcfd 0.8.2 2019-01-27 16:33:59 +05:30
Martin Algesten 9565770aa4 updated deps 2019-01-27 16:33:46 +05:30
Martin Algesten 2a48e17ae3 0.8.1 2018-12-20 15:09:13 +01:00
Martin Algesten 776a28bbdb dont use rustls logging 2018-12-20 15:09:00 +01:00
Martin Algesten 451ef0b6e3 0.8.0 2018-12-20 11:09:51 +01:00
Martin Algesten cb3d6e8124 resolved url in response 2018-12-20 11:08:39 +01:00
Martin Algesten 07fd4d2cd5 pub(crate) where we can 2018-12-20 11:08:20 +01:00
Martin Algesten 1519dcb0b1 fix redirect logic 2018-12-20 10:54:47 +01:00
Martin Algesten c685d534d0 0.7.1 2018-12-19 10:31:23 +01:00
Martin Algesten 707d194b74 rustls instead of native-tls 2018-12-19 10:30:43 +01:00
Martin Algesten 131476bd1a remove extern crate 2018-12-18 13:45:13 +01:00
Martin Algesten d2290e6b65 0.7.0 2018-12-18 13:34:38 +01:00