Commit Graph

684 Commits

Author SHA1 Message Date
Jacob Hoffman-Andrews
6a22c54ba2 Small cleanups. 2020-11-28 22:34:32 -08:00
Jacob Hoffman-Andrews
50cb5cecd1 Fix buffered DeadlineStream 2020-11-28 17:47:17 -08:00
Jacob Hoffman-Andrews
131a0264d1 Move BufReader up the stack in Stream.
Stream now has an `Inner` enum, and wraps an instance of that enum in a
BufReader. This allows Stream itself to implement BufRead trivially, and
simplify some of the match dispatching. Having Stream implement BufRead
means we can make use of `read_line` instead of our own `read_next_line`
(not done in this PR yet).

Also, removes the `Cursor` variant of the Inner enum in favor of using
the `Test` variant everywhere, since it's strictly more powerful.
2020-11-28 12:04:28 -08:00
Jacob Hoffman-Andrews
a0b88926fa Remove a keyword from Cargo.toml. (#250)
Crates has a max of 5 keywords.
2020-11-23 00:02:01 -08:00
Jacob Hoffman-Andrews
f944764ee0 Merge pull request #249 from jsha/merge-master-into-release-2.0a
Merge master into release 2.0a
2020-11-22 23:47:02 -08:00
Jacob Hoffman-Andrews
0e5cb2d018 Merge branch 'master' into merge-master-into-release-2.0a 2020-11-22 23:38:53 -08:00
Jacob Hoffman-Andrews
3d0cb33596 Add URL to Error in non-2xx case. (#243) 2020-11-22 23:36:45 -08:00
Jacob Hoffman-Andrews
de4aab7472 Tweak CHANGELOG a little bit. (#242)
Mention cloning Agent, default timeout, and removal of Request::build.
2020-11-22 23:36:25 -08:00
Jacob Hoffman-Andrews
61a6d1c5b1 Remove commented-out timeout_during_headers test. (#244)
We wound up with a second, working copy of this test at some point after
merging master into release-2.0.
2020-11-22 23:36:05 -08:00
dependabot-preview[bot]
165eae3296 Update webpki-roots requirement from 0.20 to 0.21 (#247)
Updates the requirements on [webpki-roots](https://github.com/ctz/webpki-roots) to permit the latest version.
- [Release notes](https://github.com/ctz/webpki-roots/releases)
- [Commits](https://github.com/ctz/webpki-roots/compare/v/0.20.0...v/0.21.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Jacob Hoffman-Andrews <github@hoffman-andrews.com>
2020-11-22 23:24:33 -08:00
dependabot-preview[bot]
f69725edc4 Update rustls-native-certs requirement from 0.4 to 0.5 (#248)
Updates the requirements on [rustls-native-certs](https://github.com/ctz/rustls-native-certs) to permit the latest version.
- [Release notes](https://github.com/ctz/rustls-native-certs/releases)
- [Commits](https://github.com/ctz/rustls-native-certs/compare/v/0.4.0...v/0.5.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-11-22 23:23:21 -08:00
dependabot-preview[bot]
f1cfea538d Update rustls requirement from 0.18 to 0.19 (#246)
Updates the requirements on [rustls](https://github.com/ctz/rustls) to permit the latest version.
- [Release notes](https://github.com/ctz/rustls/releases)
- [Changelog](https://github.com/ctz/rustls/blob/main/OLDCHANGES.md)
- [Commits](https://github.com/ctz/rustls/compare/v/0.18.0...v/0.19.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-11-22 23:23:12 -08:00
Jacob Hoffman-Andrews
1ec8674e88 Merge pull request #241 from jsha/changelog-2.0
Update CHANGELOG, Cargo.toml, and docs for 2.0.
2020-11-22 13:27:01 -08:00
Jacob Hoffman-Andrews
feec10b0a7 Merge pull request #240 from jsha/merge-master-into-release-2.0
Merge master into release 2.0
2020-11-22 13:26:29 -08:00
Jacob Hoffman-Andrews
c915b236ae Fix is_connection_closed. (#238)
Fixes #237.
2020-11-22 12:56:58 -08:00
Jacob Hoffman-Andrews
cc7ce757bd Update CHANGELOG, Cargo.toml, and docs for 2.0. 2020-11-22 11:09:32 -08:00
Jacob Hoffman-Andrews
1c41da87f0 Merge branch 'master' into merge-master-into-release-2.0 2020-11-22 10:25:13 -08:00
Jacob Hoffman-Andrews
96f6ed15d7 Remove "what" section of test matrix. (#239)
We were generating two whole sets of jobs, for --tests and --docs
separately. But the default invocation of cargo runs both tests and
doctests. We can save some resources and speed up our test runs by
allowing cargo to do both in one invocation.
2020-11-22 00:23:59 -08:00
Jacob Hoffman-Andrews
6a7b064f2a Remove Headers from the public API. (#224)
It turns out Headers is actually an internal-only API. None of the
user-facing types use it.

Unfortunately, making it unexported also required deleting the doctests,
since doctests can only run against a public interface.
2020-11-22 00:15:13 -08:00
Jacob Hoffman-Andrews
213d64086c Merge into_json_deserialize into into_json. (#235)
Followup to #56. At the time, doing this would have been an API
break; but we can do this as part of 2.0. This simplifies the API
nicely and creates better symmetry between sending bodies and
receiving them.
2020-11-21 22:19:13 -08:00
Jacob Hoffman-Andrews
2136f00bef Make Error Send + Sync (#236) 2020-11-21 22:11:35 -08:00
Jacob Hoffman-Andrews
e92bf0b4bb Add ureq::request_url and Agent::request_url. (#226)
These let a user pass an already-parsed Url.
2020-11-21 22:11:15 -08:00
Jacob Hoffman-Andrews
0321ea043d Add some short docstrings for types. (#225)
These types were missing a short docstring, leaving the comment space to
their right blank on the crate page.

Also, this takes advantage of intra-rustdoc links to link terms:
https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md
2020-11-21 22:10:37 -08:00
Jacob Hoffman-Andrews
420c3e2483 Merge branch 'release-2.0' into json_deserialize 2020-11-21 16:25:14 -08:00
Jacob Hoffman-Andrews
fade03b54e Rewrite the Error type. (#234)
This adds a source field to keep track of upstream errors and allow
backtraces, plus a URL field to indicate what URL an error was
associated with.

The enum variants we used to use for Error are now part of a new
ErrorKind type. For convenience within ureq, ErrorKinds can be turned
into an Error with `.new()` or `.msg("some additional information")`.

Error acts as a builder, so additional information can be added after
initial construction. For instance, we return a DnsFailed error when
name resolution fails. When that error bubbles up to Request's
`do_call`, Request adds the URL.

Fixes #232.
2020-11-21 16:14:44 -08:00
Jacob Hoffman-Andrews
271e650662 Merge into_json_deserialize into into_json. 2020-11-21 15:47:49 -08:00
Jacob Hoffman-Andrews
dac517e30e Update README and docs. (#233)
This makes src/lib.rs the primary source for crate-level documentation.
I've generated README.md with `cargo readme > README.md`. Since links to
specific documentation items should be relative when possible, but must
be absolute in README.md, I've used the new syntax for intra-rustdoc
links
(https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md),
along with a README.tpl that sets up those links to point at the
absolute versions. `cargo readme` uses the README.tpl by default.

I've also rewritten the crate level docs, removing some TODO information
at the bottom, and moving the license information to CONTRIBUTING.md.
2020-11-21 09:40:04 -08:00
Jacob Hoffman-Andrews
4fe37260a4 Update README 2020-11-19 21:38:45 -08:00
Jacob Hoffman-Andrews
c891aa31e5 Tweak sentence. 2020-11-19 21:36:23 -08:00
Jacob Hoffman-Andrews
cc72fdfca8 Add section on async 2020-11-19 21:31:23 -08:00
Jacob Hoffman-Andrews
a300ccdaad Update README and docs.
This makes src/lib.rs the primary source for crate-level documentation.
I've generated README.md with `cargo readme > README.md`. Since links to
specific documentation items should be relative when possible, but must
be absolute in README.md, I've used the new syntax for intra-rustdoc
links
(https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md),
along with a README.tpl that sets up those links to point at the
absolute versions. `cargo readme` uses the README.tpl by default.

I've also rewritten the crate level docs, removing some TODO information
at the bottom, and moving the license information to CONTRIBUTING.md.
2020-11-15 22:58:02 -08:00
Jacob Hoffman-Andrews
4cb856196e Rename some call sites for read_headers.
Fixes tests.
2020-11-15 22:35:42 +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
Jacob Hoffman-Andrews
26145810bf Add some more updates. 2020-11-15 09:14:19 +01:00
Jacob Hoffman-Andrews
daa63d3bc6 Update some more doctests.
I missed these in my previous doctest PR.

The doctests all now run without accessing the network. Tested by
turning off networking and running them.

Request.call's doctest wouldn't run because it relied on making a custom
AgentBuilder and building it, which bypasses the test_agent. I concluded
that this doctest was mostly illustrating behavior of AgentBuilder, not
call(), and simplified it to be more like the other calling methods on
request.
2020-11-15 09:14:19 +01:00
Jacob Hoffman-Andrews
203573d27c Implement more realistic doctests. (#222)
Add is_test and fn main headers to various doctests, and use real
URLs along with the ? operator.
2020-11-14 09:53:15 -08:00
Jacob Hoffman-Andrews
ec8dace1af Turn Unit into a built Request (#223)
This involved removing the Request reference from Unit, and adding an
Agent, a method, and headers.

Also, move is_retryable to Unit.
2020-11-14 01:12:01 -08:00
Jacob Hoffman-Andrews
acc36ac370 Add support for using testserver in doctests. (#218)
Doctests run against a normally-built copy of the crate, i.e. one
without #[cfg(test)] set, so we can't use the conditional compilation
feature.

Instead, define a static var that indicates whether the library is
running in test mode or not. For each doctest, insert a hidden call that
sets this var to true. Then, when ureq::agent() is called, it returns a
test_agent instead.

This required moving testserver out of the test mod and into src/, so
that it can be included unconditionally (i.e. when cfg(test) is false).

This PR converts one doctest as an example. If we land this PR, I'll
send a followup to convert the rest.
2020-11-13 10:40:16 -08:00
Jacob Hoffman-Andrews
a0b901f35b Remove qstring dependency. (#221)
Instead, rely on Url's built-in query parameter handling. A Request now
accumulates a list of query param pairs, and joins them with a parsed
URL at the time do_call is called.

In the process, remove some getters that rely on parsing the URL.
Adapting these getters was going to be awkward, and they mostly
duplicate things people can readily get by parsing the URL.
2020-11-13 00:02:52 -08:00
Jacob Hoffman-Andrews
920eccf37a Remove proxy method on request (#220) 2020-11-12 23:25:05 -08:00
Jacob Hoffman-Andrews
c2d4e527a9 1.5.1 2020-11-08 20:58:11 -08:00
Jacob Hoffman-Andrews
310c14d601 Update CHANGELOG for 1.5.2. (#216) 2020-11-08 20:40:09 -08:00
Jacob Hoffman-Andrews
d6f31ebb52 Remove some dev-dependencies. (#200)
We don't really need rayon for the parallelism in smoke-test.

Also, now that we use log, smoke-test can just use that.
2020-11-08 11:54:25 -08:00
Joshua Nelson
acaf449a4c Allow getting the error from a response (#214)
This is an alternative to https://github.com/algesten/ureq/pull/132
which does not require breaking changes.

Closes https://github.com/algesten/ureq/issues/126.
2020-11-08 11:13:03 -08: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