Skip to content

Commit

Permalink
streaming HTTP request
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts committed Nov 18, 2022
1 parent 84595b0 commit 606a68c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions examples/happy_eyeballs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ use futures::future::TryFutureExt;
use futures_concurrency::prelude::*;
use futures_time::prelude::*;

use async_std::io;
use async_std::net::TcpStream;
use futures::channel::oneshot;
use futures_concurrency::vec::AggregateError;
use futures_time::time::Duration;
use std::{error, io};
use std::error;

#[async_std::main]
async fn main() -> Result<(), Box<dyn error::Error + Send + Sync + 'static>> {
Expand All @@ -16,9 +17,7 @@ async fn main() -> Result<(), Box<dyn error::Error + Send + Sync + 'static>> {

// Make an HTTP GET request.
socket.write_all(b"GET / \r\n").await?;
let mut res = String::new();
socket.read_to_string(&mut res).await?;
println!("{res}");
io::copy(&mut socket, &mut io::stdout()).await?;

Ok(())
}
Expand Down

0 comments on commit 606a68c

Please sign in to comment.