Commit Graph

113 Commits

Author SHA1 Message Date
Jacob Hoffman-Andrews
6a88c2c8bf Clean up unused code and long imports. (#137)
This removes some commented out methods, and also changes instances of
::std::foo to use a more idiomatic import path.
2020-09-12 18:42:15 -07: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
4bc6f79847 cargo fmt 2020-08-07 21:51:35 +02:00
André Cruz
75d5e52a45 Added method to set the TLS connection builder (#116)
This allows configuring the accepted certs, client authentication,
etc, when using the native TLS crate.
2020-07-28 21:44:35 +02:00
Jacob Hoffman-Andrews
7fce93d1c8 Fix tests. 2020-07-02 23:07:53 -07:00
Jacob Hoffman-Andrews
b53de7a7ed Remove default URL_BASE of localhost. 2020-07-02 23:01:51 -07:00
Jacob Hoffman-Andrews
ea7ed88399 Request: rename path field to URL. (#104)
* Request: rename path field to URL.

This more accurately reflects its use.
2020-07-01 09:53:10 +02:00
Jacob Hoffman-Andrews
e4ad3a5e5f Remove unnecessary lifetime annotations. (#103) 2020-07-01 09:40:47 +02:00
Jacob Hoffman-Andrews
00461fb5bd Only retry idempotent requests. (#80)
This also reverts a change to send_body that was originally added to
return the number of bytes written. It's no longer needed now that we
check the size of the reader in advance.

Fixes #76.
2020-06-22 09:40:55 -07:00
Jacob Hoffman-Andrews
15be014e05 Un-deprecate read/write timeouts. (#78)
In https://github.com/algesten/ureq/pull/67#issuecomment-647112883,
Shnatsel points out that there are uses for read_timeout vs timeout. For
instance, when downloading a large file it's useful to have a read
timouet in case the download stalls, but it would be hard to pick a good
overall timeout without knowing the size of the file and the bandwidth
of the connection.
2020-06-21 14:13:22 -07:00
Jacob Hoffman-Andrews
fdc1f37662 Update documentation. (#73)
* Update documentation.

Synchronize goals section between README and rustdoc, and add two goals
(blocking API; no unsafe) that were mentioned elsewhere in the README.

Add error handling to examples for the module and for the Response
object.

And a section on synthetic errors to the top-level module documentation.

* Add back missing close brace.

* Add main function that returns Result.

* Add links to send_bytes and send_form.

* Document chunked encoding for send.

* Use a larger vec of bytes for send.
2020-06-21 09:55:50 +02:00
Jacob Hoffman-Andrews
57be414d97 Add overall timeout for requests. (#67)
This deprecates timeout_read() and timeout_write() in favor of
timeout(). The new timeout method on Request takes a Duration instead
of a number of milliseconds, and is measured against overall request
time, not per-read time.

Once a request is started, the timeout is turned into a deadline
specific to that call. The deadline is used in conjunction with the
new DeadlineStream class, which sets a timeout on each read according
to the remaining time for the request. Once the request is done,
the DeadlineStream is unwrapped via .into::<Stream>() to become
an undecorated Stream again for return to the pool. Timeouts on the
stream are unset at this point.

Still to be done:

Add a setting on Agent for default timeout.
Change header-writing code to apply overall deadline rather than
per-write timeout.
Fixes #28.
2020-06-21 09:47:35 +02:00
Martin Algesten
7a73fa1871 cargo fmt 2020-06-15 09:33:08 +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
Rob Young
2e3a75166d Allow TLS client config to be overridden
See: https://docs.rs/rustls/latest/rustls/struct.ClientConfig.html
2020-05-20 20:54:04 +02:00
bbx0
8c2d035809 Clean up dependencies 2020-04-18 11:47:49 +02:00
bbx0
55f42a614b Use &str instead of AsRef<str> to be consistent with the API 2020-04-18 11:47:49 +02:00
bbx0
3bedf9ab69 Add support for application/x-www-form-urlencoded 2020-04-18 11:47:49 +02:00
rustysec
3b0df412ef initial proxy impl 2020-03-14 09:54:54 +01:00
Martin Algesten
2956683870 bump deps, fix clippy warnings 2020-03-14 09:54:54 +01:00
Rob Young
28bdb89175 Set a default content type for JSON requests
When sending a JSON request a Content-Type of application/json is
usually wanted. This is often set as a default for JSON methods by HTTP
clients so can be confusing when it is not set. However, we do not want
to prevent the user from setting their own Content-Type.
2020-02-06 07:57:00 +01:00
Martin Algesten
4b9cfe2b67 fix clippy lints 2020-01-07 07:59:29 +01:00
Martin Algesten
fef05fd5c9 send_bytes 2019-06-21 15:53:45 +02:00
Chris West (Faux)
ceb7c3ac14 use pub(crate) instead of include!() 2019-05-27 17:44:14 +01:00
Martin Algesten
141668acba list all header names in request and response 2019-02-03 11:52:05 +05:30
Martin Algesten
1519dcb0b1 fix redirect logic 2018-12-20 10:54:47 +01:00
Martin Algesten
131476bd1a remove extern crate 2018-12-18 13:45:13 +01:00
Martin Algesten
4151aab3b4 redirects 0 2018-12-18 13:34:05 +01:00
Martin Algesten
a7f54b3647 fix redirect query parameters/hostname 2018-12-04 18:05:19 +01:00
Martin Algesten
b16b14c6aa simpler api 2018-09-04 10:59:10 +02:00
Martin Algesten
c0384c364b Url deconstruction function 2018-09-03 11:22:20 +02:00
Martin Algesten
1e536af904 get_url 2018-07-02 12:33:47 +02:00
Martin Algesten
1d541763c6 get_method 2018-07-02 12:32:01 +02:00
Martin Algesten
9cf33365e5 avoid panic for headers 2018-07-02 09:10:31 +02:00
Martin Algesten
fc1d908d9c less restrictive send() signature 2018-07-01 19:01:59 +02:00
Martin Algesten
51744804da avoid parsing when setting headers 2018-07-01 18:33:50 +02:00
Martin Algesten
2d2daf58ba doc 2018-07-01 11:13:21 +02:00
Martin Algesten
4a5944443f connection pooling 2018-06-30 16:52:54 +02:00
Martin Algesten
c5fb12a1fe code format 2018-06-30 14:57:22 +02:00
Martin Algesten
317f75f8bf set unit on response 2018-06-30 14:37:48 +02:00
Martin Algesten
54558fbb26 refactor to body 2018-06-30 14:11:54 +02:00
Martin Algesten
ff582b8c6f separate out stream 2018-06-30 13:47:37 +02:00
Martin Algesten
b54f747d16 separate out response 2018-06-30 13:36:41 +02:00
Martin Algesten
f5a4c83819 refactor into unit 2018-06-30 13:05:36 +02:00
Martin Algesten
d3ecb2bae1 method() 2018-06-27 18:07:17 +02:00
Martin Algesten
c5c878caca better debug formatting of requests 2018-06-22 16:01:51 +02:00
Martin Algesten
cd4a1722fa reduce dependency tree by features 2018-06-22 15:02:13 +02:00
Martin Algesten
e9ccf1c2cc use charset encoding for send_string 2018-06-22 11:38:44 +02:00
Martin Algesten
48dcdeb92a doc fixes 2018-06-22 11:11:59 +02:00