Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split sync and async body into distinct types #262

Merged
merged 7 commits into from
Nov 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ features = ["std", "std-future"]
[dev-dependencies]
env_logger = "0.8"
flate2 = "1.0"
futures = "0.3"
indicatif = "0.15"
rayon = "1"
static_assertions = "1.1"
Expand Down
4 changes: 2 additions & 2 deletions examples/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
use isahc::prelude::*;

fn main() -> Result<(), isahc::Error> {
futures::executor::block_on(async {
futures_lite::future::block_on(async {
let mut response = isahc::get_async("http://example.org").await?;

println!("Status: {}", response.status());
println!("Headers:\n{:?}", response.headers());
println!("Body: {}", response.text_async().await?);
println!("Body: {}", response.text().await?);

Ok(())
})
Expand Down
2 changes: 1 addition & 1 deletion examples/stream_cancellation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! a program that aborts downloading a response if it contains the byte `0x3F`
//! (ASCII "?").

use futures::{executor::block_on, io::AsyncReadExt};
use futures_lite::{future::block_on, io::AsyncReadExt};

fn main() -> Result<(), isahc::Error> {
block_on(async {
Expand Down
26 changes: 26 additions & 0 deletions examples/upload_file.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//! Sample program that demonstrates how to upload a file using a `PUT` request.
//! Since 1.0, you can use a `File` as the request body directly, or anything
//! implementing `Read`, when using the synchronous APIs.
//!
//! If using the asynchronous APIs, you will need an asynchronous version of
//! `File` such as the one provided by [`async-fs`](https://docs.rs/async-fs).
//! Isahc does not provide an implementation for you.

use isahc::prelude::*;
use std::fs::File;

fn main() -> Result<(), isahc::Error> {
// We're opening the source code file you are looking at right now for
// reading.
let file = File::open(file!())?;

// Perform the upload.
let mut response = isahc::put("https://httpbin.org/put", file)?;

// Print interesting info from the response.
println!("Status: {}", response.status());
println!("Headers: {:#?}", response.headers());
print!("{}", response.text()?);

Ok(())
}
2 changes: 1 addition & 1 deletion src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ impl AgentContext {
let handle = self.requests.remove(token);
let mut handle = self.multi.remove2(handle)?;

handle.get_mut().on_result(result);
handle.get_mut().set_result(result.map_err(Error::from));

Ok(())
}
Expand Down
247 changes: 0 additions & 247 deletions src/body.rs

This file was deleted.

Loading