Commit Graph

535 Commits

Author SHA1 Message Date
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
Jacob Hoffman-Andrews 3044ae7efd Add size limits on responses (#351)
This prevents a malicious server from running the client out of memory
by returning a very large body.

Limit into_string() to 1 megabyte.
Limit individual header fields to 100 kilobytes.
Limit number of header fields to 100.

Part of #267
2021-03-24 13:28:23 -07: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
Jacob Hoffman-Andrews 9ec4e7192a Add -k option to cureq example (#342)
By analogy with curl, this turns off certificate verification. Requires
enabling the "dangerous_configuration" feature in the rustls dependency.
2021-03-23 17:00:32 -07:00
Jacob Hoffman-Andrews a34d450657 Remove specialized error message for complete_io. (#349)
This was triggering for errors like InvalidCertificate and giving the
message "Sometimes this means the host doesn't support any of the same
ciphersuites as rustls, or doesn't support TLS 1.2 and above," which is
confusing in that situation.

For now, offer no specialized error. I'd like to come back when I find
more time and restore this, but only for the error cases where it's
useful.
2021-03-23 17:00:09 -07: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
Douman ec69c4282c Introduce Request::timeout to override agent's config 2021-02-27 10:59:54 +01:00
trevyn 1e5307cbca Fix typo: "patform" -> "platform" (#332) 2021-02-22 10:34:46 -08:00
Jacob Hoffman-Andrews b80f12e384 Offer separate error during handshakes. (#331)
It's useful to know that an error was specific to the TLS handshake,
versus the TCP connect, or a later stage of a request.
2021-02-21 14:26:25 -08:00
Jacob Hoffman-Andrews 6f86ee7f93 Add example "cureq". (#330)
Contrary to smoke-test, this takes full URLs on the commandline and
prints their contents to stdout. This makes it easier to test behavior
with specific URLs. I hope to later add flags for various behaviors like
printing headers, following redirects, enabling / disabling cookies,
and verbose output.

Also add a useful debug line when receiving a cookie header.
2021-02-21 14:26:12 -08:00
Martin Algesten 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 Algesten 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
Jacob Hoffman-Andrews 413e8bf4aa Fix imports 2021-02-21 13:32:42 -08:00
Jacob Hoffman-Andrews 671f24ab49 Offer separate error during handshakes.
It's useful to know that an error was specific to the TLS handshake,
versus the TCP connect, or a later stage of a request.
2021-02-21 13:20:38 -08: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
Nicolas 1857061859 Add a test case for LF line ending response headers 2021-02-21 09:21:18 +01:00
Nicolas a73ff2e465 Fix #321: LF header line ending 2021-02-21 09:21:10 +01:00
Jacob Hoffman-Andrews e411a629bd Changelog for 2.0.2 2021-02-21 09:00:33 +01:00
Jacob Hoffman-Andrews b246f0a9d2 Apply deadline across redirects. (#313)
Previously, each redirect could take timeout time, so a series of slow
redirects could run for longer than expected, or indefinitely.
2021-02-07 12:29:35 -08: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
Michael Diamond 0c467fee13 Add a user_agent() method to AgentBuilder to configure the default User-Agent header. (#311) 2021-01-29 17:23:30 -08:00
Jacob Hoffman-Andrews 5999421d84 Check cargo fmt in CI. 2021-01-17 21:56:28 +01:00
Martin Algesten 06abdff4bf cargo fmt (#303) 2021-01-17 11:07:52 -08:00
Jarobi 4aadda8ad3 Fix typo in doc of into_json 2021-01-17 13:51:19 +01:00
Jacob Hoffman-Andrews 0b5db55378 Bump to 2.0.1. (#289)
Update CHANGELOG.md and Cargo.toml
2021-01-10 13:34:45 -08:00
Jacob Hoffman-Andrews 1584690c95 Update CHANGELOG. 2021-01-10 13:28:07 -08:00
Jacob Hoffman-Andrews fff4c8355e Merge branch 'main' of github.com:algesten/ureq into changelog-2.0.1 2021-01-10 13:26:54 -08:00
Jacob Hoffman-Andrews 932c180d1d Response: Use ErrorKind::UnexpectedEof for "premature close" (#293)
In a client application, we're explicitly trying to differentiate "invalid data"
scenarios from "broken transfer".
2021-01-10 13:25:42 -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
Joshua Nelson d0bd2d5ea9 Use iteration instead of recursion for connect (#291)
This allows handling larger redirect chains.

Fixes #290
2021-01-05 13:55:26 -08:00
Ulrik 0ee024f8c2 Response: Use ErrorKind::UnexpectedEof for "premature close" 2021-01-05 12:07:11 +01:00
Joshua Nelson f0245aad23 Fix some clippy lints (#292)
This commit can be replicated with `cargo +nightly clippy --fix -Z unstable-options`,
plus an edit to fix another `return` missed by clippy.
2021-01-03 20:10:43 -08:00
Jacob Hoffman-Andrews 96985956aa Bump to 2.0.1.
Brings in a fix to 308 redirects.
2021-01-03 17:52:38 -08:00