Skip to content

Commit

Permalink
Updated root Cargo.toml to latest hyper and http
Browse files Browse the repository at this point in the history
- Broken build. Still more to go.
  • Loading branch information
tkmcmaster committed Jul 22, 2024
1 parent e65429d commit 317c479
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ use futures::{
sink::SinkExt,
stream, FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt,
};
use http_body_util::{combinators::BoxBody, BodyExt, Empty, StreamBody};
use hyper::{
client::HttpConnector,
body::Incoming as HyperBody,
header::{Entry as HeaderEntry, HeaderName, HeaderValue, CONTENT_DISPOSITION},
Body as HyperBody, Client, Method, Response,
Method, Response,
};
use hyper_tls::HttpsConnector;
use hyper_util::client::legacy::{
connect::{dns::GaiResolver, HttpConnector},
Client,
};
use rand::distributions::{Alphanumeric, Distribution};
use select_any::select_any;
use serde_json as json;
Expand Down Expand Up @@ -203,8 +208,7 @@ pub struct BuilderContext {
#[allow(dead_code)]
pub config_path: PathBuf,
// the http client
pub client:
Arc<Client<HttpsConnector<HttpConnector<hyper::client::connect::dns::GaiResolver>>>>,
pub client: Arc<Client<HttpsConnector<HttpConnector<GaiResolver>>, HyperBody>>,
// a mapping of names to their prospective providers
pub providers: Arc<BTreeMap<String, providers::Provider>>,
// a mapping of names to their prospective loggers
Expand Down Expand Up @@ -498,7 +502,9 @@ fn multipart_body_as_hyper_body(
let piece_stream = future::ok(Bytes::from(piece_data)).into_stream();
tweak_path(&mut body, &multipart_body.path);
let a = create_file_hyper_body(body).map_ok(move |(bytes, body)| {
let stream = piece_stream.chain(body).a();
// let reader_stream = tokio_util::io::ReaderStream::new(body.into_data_stream());
// let body: StreamBody<Bytes> = StreamBody::new(body.into_data_stream());
let stream = piece_stream.chain(body.into_data_stream()).a();
(bytes + piece_data_bytes, stream)
});
Either::A(a)
Expand Down Expand Up @@ -539,6 +545,8 @@ fn multipart_body_as_hyper_body(
.flatten()
.chain(stream::once(future::ok(closing_boundary)));

// let body = StreamBody::new(stream);
// let body: Incoming = body.into();
(bytes, HyperBody::wrap_stream(stream))
});
Ok(ret)
Expand Down Expand Up @@ -569,6 +577,7 @@ async fn create_file_hyper_body(filename: String) -> Result<(u64, HyperBody), Te
}
});

// let body = StreamBody::new(stream);
let body = HyperBody::wrap_stream(stream);
Ok((bytes, body))
}
Expand All @@ -592,7 +601,7 @@ fn body_template_as_hyper_body(
);
return Either3::A(future::ready(r).and_then(|x| x));
}
BodyTemplate::None => return Either3::B(future::ok((0, HyperBody::empty()))),
BodyTemplate::None => return Either3::B(future::ok((0, Empty::<Bytes>::new()))),
BodyTemplate::String(t) => t,
};
let mut body = match template.evaluate(Cow::Borrowed(template_values.as_json()), None) {
Expand Down Expand Up @@ -622,7 +631,7 @@ pub type StatsTx = futures_channel::UnboundedSender<stats::StatsMessage>;

pub struct Endpoint {
body: BodyTemplate,
client: Arc<Client<HttpsConnector<HttpConnector<hyper::client::connect::dns::GaiResolver>>>>,
client: Arc<Client<HttpsConnector<HttpConnector<GaiResolver>>, HyperBody>>,
headers: Vec<(String, Template)>,
max_parallel_requests: Option<NonZeroUsize>,
method: Method,
Expand Down

0 comments on commit 317c479

Please sign in to comment.