Commit Graph

510 Commits

Author SHA1 Message Date
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
Jacob Hoffman-Andrews be6be7e600 Fix test 2020-12-05 15:29:11 +01:00
Jacob Hoffman-Andrews 18a9b08973 Revert deletions of client_error and friends. 2020-12-05 15:29:11 +01:00
Jacob Hoffman-Andrews 64ebd47979 Add nicer doctest; revert smoke-test. 2020-12-05 15:29:11 +01:00
Jacob Hoffman-Andrews 5a55f94101 Improve smoke-test.rs 2020-12-05 15:29:11 +01:00
Jacob Hoffman-Andrews 814b10ceaf Update smoke-test. 2020-12-05 15:29:11 +01:00
Jacob Hoffman-Andrews 219185f73f Make Error an enum again. 2020-12-05 15:29:11 +01:00
Jacob Hoffman-Andrews b20c4fc3be Revert diff 2020-12-05 15:29:11 +01:00
Jacob Hoffman-Andrews 3cd160279f Revert diff 2020-12-05 15:29:11 +01:00
Jacob Hoffman-Andrews f9378ab089 Replace Error::status and Error::into_response with http. 2020-12-05 15:29:11 +01:00
Jacob Hoffman-Andrews d267dffde1 Snapshow of match variant. 2020-12-05 15:29:11 +01:00
Jacob Hoffman-Andrews 33066fb074 Improve doctest comments. 2020-12-05 15:29:11 +01:00
Jacob Hoffman-Andrews 2167cf2481 Interlink docs 2020-12-05 15:29:11 +01:00
Jacob Hoffman-Andrews 71a7e3298d Add documentation for handling statuses. 2020-12-05 15:29:11 +01:00
Jacob Hoffman-Andrews 4c3b93d86d Add Error::{kind, status, into_response}.
Also, remove Response::{ok, error, client_error, server_error,
redirect}. The idea is that you would access these through the
Error object instead.

I fetched all the reverse dependencies of ureq on crates.io and looked
for uses of the methods being removed. I found none.

I'm also considering removing the error_on_non_2xx method entirely. If
it's easy to get the underlying response for errors, it would be nice to
make that the single way to do things rather than support two separate
ways of handling HTTP errors.
2020-12-05 15:29:11 +01:00
Jacob Hoffman-Andrews 35c03521b9 Add debug logs for stream pooling. 2020-12-05 15:05:20 +01:00
Joshua Nelson 37f991fa50 Make sure the redirects doctest actually tests something for 301 redirects 2020-12-05 15:03:47 +01:00
Joshua Nelson 4a3d3c49a1 Note that 307 redirects aren't followed in the docs 2020-12-05 15:03:47 +01:00
Joshua Nelson 6bab430d29 Only follow 307/308 redirects for methods without a body 2020-12-05 15:03:47 +01:00
Joshua Nelson 8d21052c7e Follow 307/308 redirects 2020-12-05 15:03:47 +01:00
Jacob Hoffman-Andrews 7afc4b04f3 Use BufRead in more places (#261)
This moves Stream's enum into an `Inner` enum, and wraps a single
BufReader around the whole thing. This makes it easier to consistently
treat the contents of Stream as being wrapped in a BufReader.

Also, implement BufRead for DeadlineStream. This means when a timeout
is set, we don't have to set that timeout on the socket with every
small read, just when we fill up the buffer. This reduces the number
of syscalls.

Remove the `Cursor` variant from Stream. It was strictly less powerful
than that `Test` variant, so I've replaced the handful of Cursor uses
with `Test`. Because some of those cases weren't test, I removed the
`#[cfg(test)]` param on the `Test` variant.

Now that all inputs to `do_from_read` are `impl BufRead`, add that
as a type constraint. Change `read_next_line` to take advantage of
`BufRead::read_line`, which may be somewhat faster (though I haven't
benchmarked).
2020-11-30 09:23:19 -08:00
messense df1f4bd0e1 Replace unmaintained encoding crate with encoding_rs 2020-11-29 19:38:39 +01:00
Jacob Hoffman-Andrews 36b307423c Fix non-tls case correctly. 2020-11-29 00:02:37 -08:00
Jacob Hoffman-Andrews 6b6a59f215 Fix non-tls case. 2020-11-28 23:57:02 -08:00
Jacob Hoffman-Andrews a286a7a22d Make DeadlineStream Read use the BufRead. 2020-11-28 23:33:28 -08:00
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