implement oneshot
This commit is contained in:
@@ -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<reqwest::Response, HttpSwardError> {
|
||||
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<BoxError>),
|
||||
|
||||
#[error(transparent)]
|
||||
MultiplexError(#[from] MultiplexedSwardError<reqwest::Error>),
|
||||
|
||||
#[error(transparent)]
|
||||
BadUrl(#[from] url::ParseError)
|
||||
}
|
||||
BadUrl(#[from] url::ParseError),
|
||||
}
|
||||
|
||||
@@ -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<SimpleHttpRequest> for SimpleHttpSward {
|
||||
type Response = reqwest::Response;
|
||||
type Error = reqwest::Error;
|
||||
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;
|
||||
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;
|
||||
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user