Move Agent construction to new AgentBuilder.
In the process, rename set_foo methods to just foo, since methods on the builder will always be setters. Adds a new() method on ConnectionPool so it can be constructed directly with the desired limits. Removes the setter methods on ConnectionPool for those limits. This means that connection limits can only be set when an Agent is built. There were two tests that verify Send and Sync implementations, one for Agent and one for Request. This PR moves the Request test to request.rs, and changes both tests to more directly verify the traits. There may be another way to do this, I'm not sure.
This commit is contained in:
committed by
Martin Algesten
parent
0f083a4436
commit
30162bf3bb
@@ -120,6 +120,7 @@ mod serde_macros;
|
||||
mod test;
|
||||
|
||||
pub use crate::agent::Agent;
|
||||
pub use crate::agent::AgentBuilder;
|
||||
pub use crate::error::Error;
|
||||
pub use crate::header::Header;
|
||||
pub use crate::proxy::Proxy;
|
||||
@@ -135,7 +136,7 @@ pub use serde_json::{to_value as serde_to_value, Map as SerdeMap, Value as Serde
|
||||
|
||||
/// Agents are used to keep state between requests.
|
||||
pub fn agent() -> Agent {
|
||||
Agent::new().build()
|
||||
Agent::default()
|
||||
}
|
||||
|
||||
/// Make a request setting the HTTP method via a string.
|
||||
@@ -144,7 +145,7 @@ pub fn agent() -> Agent {
|
||||
/// ureq::request("GET", "http://example.com").call().unwrap();
|
||||
/// ```
|
||||
pub fn request(method: &str, path: &str) -> Request {
|
||||
Agent::new().request(method, path)
|
||||
agent().request(method, path)
|
||||
}
|
||||
|
||||
/// Make a GET request.
|
||||
|
||||
Reference in New Issue
Block a user