feat(client): add a new Client struct with super powers
- Includes ergonomic traits like IntoUrl and IntoBody, allowing easy usage. - Client can have a RedirectPolicy. - Client can have a SslVerifier. Updated benchmarks for client. (Disabled rust-http client bench since it hangs.)
This commit is contained in:
34
README.md
34
README.md
@@ -42,18 +42,18 @@ Client:
|
||||
|
||||
```rust
|
||||
fn main() {
|
||||
// Create a client.
|
||||
let mut client = Client::new();
|
||||
|
||||
// Creating an outgoing request.
|
||||
let mut req = Request::get(Url::parse("http://www.gooogle.com/").unwrap()).unwrap();
|
||||
let mut res = client.get("http://www.gooogle.com/")
|
||||
// set a header
|
||||
.header(Connection(vec![Close]))
|
||||
// let 'er go!
|
||||
.send();
|
||||
|
||||
// Setting a header.
|
||||
req.headers_mut().set(Connection(vec![Close]));
|
||||
|
||||
// Start the Request, writing headers and starting streaming.
|
||||
let res = req.start().unwrap()
|
||||
// Send the Request.
|
||||
.send().unwrap()
|
||||
// Read the Response.
|
||||
.read_to_string().unwrap();
|
||||
// Read the Response.
|
||||
let body = res.read_to_string().unwrap();
|
||||
|
||||
println!("Response: {}", res);
|
||||
}
|
||||
@@ -64,22 +64,20 @@ fn main() {
|
||||
[Client Bench:](./benches/client.rs)
|
||||
|
||||
```
|
||||
|
||||
running 3 tests
|
||||
test bench_curl ... bench: 298416 ns/iter (+/- 132455)
|
||||
test bench_http ... bench: 292725 ns/iter (+/- 167575)
|
||||
test bench_hyper ... bench: 222819 ns/iter (+/- 86615)
|
||||
test bench_curl ... bench: 400253 ns/iter (+/- 143539)
|
||||
test bench_hyper ... bench: 181703 ns/iter (+/- 46529)
|
||||
|
||||
test result: ok. 0 passed; 0 failed; 0 ignored; 3 measured
|
||||
test result: ok. 0 passed; 0 failed; 0 ignored; 2 measured
|
||||
```
|
||||
|
||||
[Mock Client Bench:](./benches/client_mock_tcp.rs)
|
||||
|
||||
```
|
||||
running 3 tests
|
||||
test bench_mock_curl ... bench: 25254 ns/iter (+/- 2113)
|
||||
test bench_mock_http ... bench: 43585 ns/iter (+/- 1206)
|
||||
test bench_mock_hyper ... bench: 27153 ns/iter (+/- 2227)
|
||||
test bench_mock_curl ... bench: 53987 ns/iter (+/- 1735)
|
||||
test bench_mock_http ... bench: 43569 ns/iter (+/- 1409)
|
||||
test bench_mock_hyper ... bench: 20996 ns/iter (+/- 1742)
|
||||
|
||||
test result: ok. 0 passed; 0 failed; 0 ignored; 3 measured
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user