interop: make h3_get() faster and return the size read
@@ -11,7 +11,6 @@ use futures::future;
use lazy_static::lazy_static;
use quinn_h3::Settings;
use structopt::StructOpt;
-use tokio::io::AsyncReadExt;
use tracing::{error, info, warn};
#[derive(StructOpt, Debug)]
@@ -659,14 +658,17 @@ fn build_result(
result
}
-async fn h3_get(conn: &quinn_h3::client::Connection, uri: &http::Uri) -> Result<()> {
+async fn h3_get(conn: &quinn_h3::client::Connection, uri: &http::Uri) -> Result<usize> {
let (response, _) = conn.send_request(http::Request::get(uri).body(())?).await?;
let (_, mut recv_body) = response.await?;
- let mut body = Vec::with_capacity(1024);
- recv_body.read_to_end(&mut body).await?;
- Ok(())
+ let mut total_len = 0usize;
+ while let Some(d) = recv_body.data().await {
+ total_len += d?.len()
+ }
+
+ Ok(total_len)
}
async fn get(stream: (quinn::SendStream, quinn::RecvStream)) -> Result<Vec<u8>> {
