diff --git a/ubw-sward/src/http/integrated.rs b/ubw-sward/src/http/integrated.rs index eef7292..ba4ccab 100644 --- a/ubw-sward/src/http/integrated.rs +++ b/ubw-sward/src/http/integrated.rs @@ -8,7 +8,7 @@ use std::net::{IpAddr, SocketAddr}; use std::sync::Arc; use thiserror::Error; use tower::ServiceExt; -use tower::Service; +use tower::{BoxError, Service}; use url::Url; use wyrand::WyRand; @@ -27,15 +27,19 @@ impl IntegratedHttpSward { pub async fn oneshot(&mut self) -> Result { let url = match &mut self.attack_target { AttackTarget::Random(random) => random.generate_url()?, - AttackTarget::Fixed(url) => url.clone() + AttackTarget::Fixed(url) => url.clone(), }; - let request = SimpleHttpRequest { - body: None, - url - }; - let res = self.request_sender.ready()?.call(request); + let request = SimpleHttpRequest { body: None, url }; + let res = self + .request_sender + .ready() + .await + .map_err(HttpSwardError::MultiplexError)? + .call(request) + .await + .map_err(HttpSwardError::MultiplexError)?; - todo!() + Ok(res) } } @@ -201,12 +205,9 @@ pub enum HttpSwardBuildError { #[derive(Debug, Error)] pub enum HttpSwardError { - #[error("Http Response: {0}")] - HttpCode(u8), + #[error("Error when pooling")] + MultiplexError(MultiplexedSwardError), #[error(transparent)] - MultiplexError(#[from] MultiplexedSwardError), - - #[error(transparent)] - BadUrl(#[from] url::ParseError) -} \ No newline at end of file + BadUrl(#[from] url::ParseError), +} diff --git a/ubw-sward/src/http/simple.rs b/ubw-sward/src/http/simple.rs index 62659fb..6f6f009 100644 --- a/ubw-sward/src/http/simple.rs +++ b/ubw-sward/src/http/simple.rs @@ -1,9 +1,10 @@ use bytes::Bytes; use reqwest::header::HeaderMap; use reqwest::{Client, Method}; +use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; -use tower::{Service, ServiceExt}; +use tower::Service; use tower::balance::p2c::Balance; use tower::discover::ServiceList; use url::Url; @@ -52,7 +53,7 @@ pub struct SimpleHttpRequest { impl Service for SimpleHttpSward { type Response = reqwest::Response; type Error = reqwest::Error; - type Future = Pin>>>; + type Future = Pin> + Send>>; fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) }