Skip to content

Commit

Permalink
fix: cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
average-gary committed Dec 31, 2024
1 parent 6b921de commit 59679e0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
10 changes: 6 additions & 4 deletions src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ pub enum HttpError {
#[snafu(display("Failed to build HTTP request: {}", source))]
BuildRequest { source: http::Error },
#[snafu(display("Expected 401 with Digest Auth"))]
DigestAuthExpectation
DigestAuthExpectation,
}

impl HttpError {
pub const fn is_retriable(&self) -> bool {
match self {
HttpError::BuildRequest { .. } | HttpError::MakeProxyConnector { .. } | HttpError::DigestAuthExpectation => false,
HttpError::BuildRequest { .. }
| HttpError::MakeProxyConnector { .. }
| HttpError::DigestAuthExpectation => false,
HttpError::CallRequest { .. }
| HttpError::BuildTlsConnector { .. }
| HttpError::MakeHttpsConnector { .. } => true,
Expand Down Expand Up @@ -298,7 +300,7 @@ pub enum Auth {
token: SensitiveString,
},
/// Digest authentication.
///
///
/// requires a round trip to the server to get the challenge and then send the response
Digest {
/// The digest authentication username.
Expand Down Expand Up @@ -352,7 +354,7 @@ impl Auth {
Auth::Digest { user, password } => {
let auth = Authorization::basic(user.as_str(), password.inner());
map.typed_insert(auth);
},
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sinks/databend/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl SinkConfig for DatabendConfig {
}
Some(Auth::Digest { .. }) => {
return Err("Digest authentication is not supported currently".into());
},
}
None => {}
}
if let Some(database) = &self.database {
Expand Down
2 changes: 1 addition & 1 deletion src/sinks/prometheus/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ fn authorized<T: HttpBody>(req: &Request<T>, auth: &Option<Auth>) -> bool {
),
Auth::Bearer { token } => {
HeaderValue::from_str(format!("Bearer {}", token.inner()).as_str())
},
}
Auth::Digest { .. } => {
error!("Digest authentication is not supported.");
return false;
Expand Down
5 changes: 2 additions & 3 deletions src/sources/util/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ use futures_util::{stream, FutureExt, StreamExt, TryFutureExt};
use http::{response::Parts, Uri};
use hyper::{Body, Request};
use md5::Digest;
use vector_lib::sensitive_string::SensitiveString;
use std::time::Duration;
use std::{collections::HashMap, future::ready};
use tokio_stream::wrappers::IntervalStream;
use vector_lib::json_size::JsonSize;
use vector_lib::sensitive_string::SensitiveString;

use crate::{
http::{Auth, HttpClient},
Expand Down Expand Up @@ -178,7 +178,6 @@ pub(crate) async fn call<

// building an empty request should be infallible
let mut request = builder.body(Body::empty()).expect("error creating request");

let mut is_digest = false;
let mut username = "".to_string();
let mut user_password = SensitiveString::default();
Expand All @@ -193,7 +192,7 @@ pub(crate) async fn call<
_ => false
};
}

tokio::time::timeout(inputs.timeout, client.send(request))
.then({
let headers_value = headers.clone();
Expand Down

0 comments on commit 59679e0

Please sign in to comment.