0d0d3635476ba22e5a2b39b0e4b243f57f1f36d2
If the runtime is dropped while a DNS request is being made, it can
lead to a panic. This patch checks if the task was cancelled, and
returns a generic IO error instead of panicking in that case.
The following code reproduces the problem on my macOS machine:
```
use hyper::Client;
use tokio::runtime;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
fn main() {
let rt = runtime::Builder::new()
.threaded_scheduler()
.core_threads(1)
.enable_all()
.build()
.unwrap();
// spawn a request and then drop the runtime immediately
rt.spawn(fetch_url());
}
async fn fetch_url() -> Result<()> {
let url: hyper::Uri = "http://example.com".parse()?;
let client = Client::builder().build_http::<hyper::Body>();
let res = client.get(url).await?;
println!("Response: {}", res.status());
Ok(())
}
```
hyper
A fast and correct HTTP implementation for Rust.
- HTTP/1 and HTTP/2
- Asynchronous design
- Leading in performance
- Tested and correct
- Extensive production use
- Client and Server APIs
Get started by looking over the guides.
"Low-level"
hyper is a relatively low-level library, meant to be a building block for libraries and applications.
If you are looking for a convenient HTTP client, then you may wish to consider reqwest. If you are looking for a convenient HTTP server, then you may wish to consider warp. Both are built on top of this library.
Contributing
To get involved, take a look at CONTRIBUTING.
There are two main avenues for real-time chatting about hyper: a Gitter room and irc.mozilla.org/hyper. They are mirrored, so choose whichever format you prefer.
License
hyper is provided under the MIT license. See LICENSE.
Languages
Rust
94.5%
C
5.2%
Shell
0.3%