Commit Graph
100 Commits
Author SHA1 Message Date
Martin Algesten 4ed42088b7 Add -m and -ct to cureq example 2021-08-23 21:11:27 +02:00
Martin Algesten 485647d5de Fix proxy urls that end with trailing slash
Close #402
2021-08-23 20:57:29 +02:00
Martin Algesten 641eb3df10 Fix overlapping redirect tests
Two tests were using /redirect_post1, which breaks if they are running in parallel.
2021-08-23 20:52:08 +02:00
Martin Algesten 526eb7b9e0 Fix clippy lints 2021-08-23 20:45:33 +02:00
Martin Algesten 989995d1ba Fix clippy lints (#387) 2021-05-11 18:05:17 -07:00
Martin Algesten 4ade506047 Allow upper_case_acronyms 2021-04-17 12:30:39 +02:00
Martin Algesten a6085d8237 Install/use rust toolchain for Lint step 2021-04-17 12:16:56 +02:00
Martin Algesten e70fdcc797 2.1.0 2021-03-26 07:45:11 +01:00
Martin Algesten 1199432cfe Changelog for 2.1.0 2021-03-26 07:45:11 +01:00
Martin Algesten 3cfa9e6b35 Refactor into_string body reading 2021-03-25 21:49:39 +01:00
Martin Algesten 7c6ed53df3 Move Response::unit and stream to the heap 2021-03-25 21:04:12 +01:00
Martin Algesten cfaca317c6 Provide url in Response Debug impl 2021-03-25 07:45:34 +01:00
Martin Algesten 40e156e2a3 Url access functions for Request (simpler) 2021-03-24 20:58:47 +01:00
Martin Algesten 8f16b53c19 Run clippy in CI lint 2021-03-24 20:29:43 +01:00
Martin Algesten b42e9afd71 Fix clippy warnings 2021-03-24 20:29:43 +01:00
Martin Algesten ea53c7cedd Use is_tchar for cookie name check 2021-03-24 20:09:27 +01:00
Martin Algesten 5c9b1b9a0c Enforce cookie RFC name/value rules 2021-03-24 20:09:27 +01:00
Martin Algesten c5c40cf138 Stop percent encoding cookies 2021-03-24 20:09:27 +01:00
Martin Algesten 026cf75690 Handle non-utf8 status and headers
Non-utf8 headers are ignored and reading the value for them will
yield `None`.
2021-03-14 23:14:43 +01:00
Martin Algesten 9a9dd4ee6c Upgrade cookie to 0.15 and cookie_store to 0.13.0
cookie_store default features pulls in reqwest, so we stop that
by specifying the exact features wanted.
2021-03-14 19:00:28 +01:00
Martin Algesten 0dc609fc30 Ensure Error and Response implement Send+Sync
This is to ensure we don't accidentally introduce breaking changes
with respects to Send and Sync.
2021-03-14 19:00:04 +01:00
Martin Algesten 91cb0ce5fc Move unit tests inside conditionally compiled mod tests { } blocks
Idiomatic rust organizes unit tests into `mod tests { }` blocks
using conditional compilation `[cfg(test)]` to decide whether to
compile the code in that block.

This commit moves "bare" test functions into such blocks, and puts
the block at the bottom of respective file.
2021-03-14 18:56:09 +01:00
Martin Algesten 239ba342a2 Provide .method() and .query_params() 2021-03-14 09:46:40 +01:00
Martin Algesten c4c1618042 Remove unnecessary cloning in Request::do_call() 2021-03-14 09:46:40 +01:00
Martin Algesten 566295bebb Provide context for errors when reading status line and headers
The HTTP spec allows for non-ascii values both in the status line and
in headers. ureq does not handle that, we can however provide better
context for when it happens.
2021-03-13 23:03:25 +01:00
Martin Algesten a66abdd285 Provide ipv6 example 2021-03-02 19:50:20 +01:00
Martin AlgestenandJacob Hoffman-Andrews 7222931b24 Update src/response.rs
Co-authored-by: Jacob Hoffman-Andrews <github@hoffman-andrews.com>
2021-02-21 23:20:58 +01:00
Martin Algesten ea83edc609 Allow status lines with missing reason phrase
The spec says the reason phrase at least must be a space. However in
the wild, there are sites that just ends after the status code.
To be more compatible, this commit relaxes ureq's parsing.

Close #316
2021-02-21 23:20:58 +01:00
Martin AlgestenandJacob Hoffman-Andrews dc0069670d Update src/response.rs
Co-authored-by: Jacob Hoffman-Andrews <github@hoffman-andrews.com>
2021-02-21 23:20:20 +01:00
Martin Algesten 281a8462b5 Clarify doc
Close #326
2021-02-21 23:20:20 +01:00
Martin Algesten c833acfe5c 2.0.2 2021-02-21 09:30:57 +01:00
Martin Algesten d76c0e7910 Update changelog for 2.0.2 2021-02-21 09:28:50 +01:00
Martin Algesten d627ef9704 OrAnyStatus::or_any_status ergonomic helper
Some users might prefer to handle all HTTP responses as Response
regardless of status code.
2021-01-30 09:40:45 +01:00
Martin Algesten 06abdff4bf cargo fmt (#303) 2021-01-17 11:07:52 -08:00
Martin Algesten 948f736125 Document proxy support (#298)
ureq supports proxying using HTTP CONNECT and SOCKS5, the features are however
missing documentation. This brings it to the lib.rs doc.
2021-01-09 09:58:07 -08:00
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