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.
This commit is contained in:
Christoph Herzog
2019-03-22 13:42:48 +01:00
committed by Sean McArthur
parent c45ff29bfb
commit 954fdfae30
8 changed files with 640 additions and 5 deletions

View File

@@ -10,6 +10,9 @@ readme = "README.md"
license = "MIT/Apache-2.0"
categories = ["web-programming::http-client"]
[package.metadata.docs.rs]
all-features = true
[dependencies]
base64 = "0.10"
bytes = "0.4"
@@ -43,6 +46,9 @@ socks = { version = "0.3.2", optional = true }
tokio-rustls = { version = "0.9", optional = true }
trust-dns-resolver = { version = "0.10", optional = true }
webpki-roots = { version = "0.16", optional = true }
cookie_store = "0.5.1"
cookie = "0.11.0"
time = "0.1.42"
[dev-dependencies]
env_logger = "0.6"
@@ -63,6 +69,3 @@ rustls-tls = ["hyper-rustls", "tokio-rustls", "webpki-roots", "rustls", "tls"]
trust-dns = ["trust-dns-resolver"]
hyper-011 = ["hyper-old-types"]
[package.metadata.docs.rs]
all-features = true