Commit Graph

48 Commits

Author SHA1 Message Date
Jonas Platte
1be9c34f01 Make ResponseBuilderExt not target-dependent 2021-08-26 13:42:46 -07:00
Sean McArthur
87a09322d6 Make the async Client default (#626)
The previously default Client is moved to `reqwest::blocking`, while the
async client becomes the main API.

Closes #622
2019-09-09 17:20:51 -07:00
Sean McArthur
ba7b2a754e refactor all to async/await (#617)
Co-authored-by: Danny Browning <danny.browning@protectwise.com>
Co-authored-by: Daniel Eades <danieleades@hotmail.com>
2019-09-06 17:22:56 -07:00
danieleades
cf8944a0f0 cargo fmt (#604)
Run rustfmt and setup CI to check for it.
2019-08-29 09:52:39 -07:00
Daniel Eades
4bb4149b63 remove unnecessary double-colons 2019-08-16 12:59:55 -07:00
Daniel Eades
86d9cbc66e cargo fix --edition 2019-08-16 12:59:55 -07:00
messense
1e7c9fe507 Sync Response::text() & Response::json() call their async version 2019-06-26 11:11:07 -07:00
Sean McArthur
5096e12fa2 Use executor::enter before blocking a thread in wait 2019-06-05 14:41:53 -07:00
nirasan
9f22f46e85 Clarify correct specification of dependency on serde (#525)
Closes #494
2019-05-16 10:46:00 -07:00
Ziyang Li
40550aec7a Allow user to specify a default encoding when reading Response to text (#511)
Add a function `text_with_charset` which allows the user to provide a default charset encoding. The behavior of this still prefers the provided charset inside the http header over the provided default encoding.
2019-04-29 11:47:01 -07:00
Christoph Herzog
9935a8e117 CookieStore cleanup/fixes
* Remove TODO
* Remove Cookie::set_ setters
* Do not expose SameSite enum, provide getters on Cookie instead
* Simplify Response::cookies signature (now ignores errors)
2019-04-09 12:54:10 -07:00
Christoph Herzog
954fdfae30 Implement cookie store support
This commit introduces a cookie store / session support
for both the async and the sync client.

Functionality is based on the cookie crate,
which provides a HTTP cookie abstraction,
and the cookie_store crate which provides a
store that handles cookie storage and url/expiration
based cookie resolution for requests.

Changes:
* adds new private dependencies: time, cookie, cookie_store
* a new cookie module which provides wrapper types around
    the dependency crates
* a Response::cookies() accessor for iterating over response cookies
* a ClientBuilder::cookie_store() method that enables session functionality
* addition of a cookie_store member to the async client
* injecting request cookies and persisting response cookies
* cookie tests

NOTE: this commit DOES NOT expose the CookieStore itself,
limiting available functionality.

This is desirable, but omitted for now due to API considerations that should be fleshed out in the future.
This means users do not have direct access to the cookie session for now.
2019-04-09 12:54:10 -07:00
Michael Habib
e49f5ee404 add Response::error_for_status_ref to allow borrowing (#457) 2019-02-15 14:33:18 -08:00
Sean McArthur
68e98d54ea Add Response::content_length() method 2019-01-18 11:42:27 -08:00
Danilo Bargen
4aa34bb591 Response.copy_to: Fix docs markup 2018-11-19 09:49:15 -08:00
Sean McArthur
478ef9bf15 add Response::remote_addr() method
The new `remote_addr` method returns an `Option<SocketAddr>`, which is
`Some` if the underlying transport uses socket addresses.

Closes #373
2018-10-26 14:23:33 -07:00
Yannick Heinrich
647f59756e Add missing pub(crate) statements. 2018-10-05 11:19:52 -07:00
Paul Woolcock
4857a5917d From<http::Response> for Response (#360)
This adds an implementation to convert a `Response` type from the `http`
crate to the `async_impl::Response` type. This is the first step to
allow us to convert `http::Response` objects to `request::Response`
objects

This also adds an extension trait for the `http::response::Builder`
type. The `http::Response` object does not provide a way to access the
"final" url that the response is derived from, so we can't easily
provide that in the `From<http::Response>` implementation. For users who
are manually constructing `http::Response` objects for use in tests,
etc, they can import this extension trait, which adds a `.url()` builder
method that will allow them to pass a `Url`, which we then convert to
our newtype'd Url and add to the `http::Response`'s `extensions`. Then,
when converting from `http::Response` to `async_impl::Response` we can
pull that value out of the `extensions` and use it to construct the
`async_impl::Response`

Closes #333
2018-10-04 17:38:26 -07:00
Sean McArthur
449ec8f1f3 remove extra size_of tests 2018-09-19 15:28:20 -07:00
Sean McArthur
0735e586e5 reduce size of Response, async::Response, and async::Decoder 2018-09-19 15:23:01 -07:00
Sean McArthur
b95de15587 change Response::version() to return Version by value 2018-09-11 14:22:21 -07:00
Yash Srivastav
12cfbafc28 Add support for getting HTTP version of a response 2018-07-31 13:53:42 -07:00
Yash Srivastav
c417d6dab8 Upgrade hyper to 0.12
Closes #304
2018-07-05 10:03:31 -07:00
Sean McArthur
cf5deac02d document that Response::text consumes the body
Closes #302
2018-05-31 12:02:06 -07:00
messense
0203fad886 Detect encoding in Response::text() (#256)
* Detect encoding and decode text response

Fixes #246

* Try to get encoding from Content-Type header

* Remove uchardet encoding detection for now

* Add non utf-8 test case for Response::text()

* Reduce copies
2018-02-15 11:01:57 -08:00
knight42
2c60511bce fix(response): copy_to() and text() return reqwest::Result 2017-10-27 15:10:31 +08:00
knight42
2fbc20167d feat: add Response::text() 2017-10-27 14:58:16 +08:00
knight42
c0896f1986 Add Response::copy_to 2017-10-18 09:21:36 +08:00
Sean McArthur
779f8080ef change Builders to only error at the end
Closes #189
2017-08-31 18:10:45 -07:00
Ashley Mannix
2cb70c872a make body return borrowed decoder 2017-08-19 18:02:20 +10:00
Ashley Mannix
e2fa97254e support async gzip decoding 2017-08-18 19:43:06 +10:00
Sean McArthur
12ee6fbcde small improvements to docs 2017-07-13 12:17:38 -07:00
Tom Prince
855e6615eb Add error_for_status.
This makes it it easy to turn error responses into error
results.
2017-06-22 11:03:39 -07:00
Sean McArthur
665b4fe718 upgrade hyper to v0.11 2017-06-21 09:47:21 -07:00
James Kominick
3de6f24785 Response doc improvements
- Add doc examples for the usage of `Response`s `url`, `status`,
  and `headers` methods
2017-06-08 23:28:35 -04:00
Sean McArthur
cb9a45b8a4 change Response::status() to return StatusCode by value 2017-06-07 18:11:05 -07:00
Michal Budzynski
e3bf6756f4 Added missing "Errors" and "Panics" sections to request.rs and response.rs 2017-06-04 04:49:33 +02:00
Sean McArthur
7fc47fb908 remove all public mention of HttpVersion
Closes #123
2017-06-01 17:02:59 -07:00
Tom Prince
a2c24a4009 Some slightly less trivial rustfmt changes. 2017-05-31 14:50:32 -06:00
Tom Prince
4c60e6d35f Really trivial rustfmt changes. 2017-05-31 14:50:32 -06:00
James Kominick
812c220e61 update doc examples
- Make examples runnable for doc tests
- Add error handling using `?` instead of `unwrap`
2017-05-21 17:14:32 -04:00
Corey Farwell
c367a7034f Add full example for Response::json. 2017-05-12 00:04:17 -04:00
Sean McArthur
f6109840f1 some info! logs for Request and Response 2017-05-09 15:30:29 -07:00
Ted Driggs
5947578a28 Change trait to DeserializeOwned 2017-05-09 13:42:50 -07:00
Sean McArthur
d514d4e6e8 redirect and error reform
- `Error` has been made an opaque struct.
- `RedirectPolicy` now makes use of `RedirectAttempt` and `RedirectAction`.
2017-05-08 11:38:48 -07:00
Sean McArthur
3cc4d654a3 fix panic from Gzip reading an empty stream
Closes #82
2017-05-05 11:50:07 -07:00
Cyril Plisko
44c7ccb46d Expose the final response URL 2017-04-07 17:40:55 +03:00
Sean McArthur
4d68979523 move Response pieces into its own response module 2017-04-05 16:48:32 -07:00