mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-05 02:18:16 +00:00
http: clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
5e630472ec
commit
94d388b988
@ -170,6 +170,7 @@ impl hyper::service::Service<Uri> for HttpsConnector {
|
|||||||
|
|
||||||
if use_connect {
|
if use_connect {
|
||||||
async move {
|
async move {
|
||||||
|
use std::fmt::Write as _;
|
||||||
let tcp_stream = connector.call(proxy_uri).await.map_err(|err| {
|
let tcp_stream = connector.call(proxy_uri).await.map_err(|err| {
|
||||||
format_err!("error connecting to {} - {}", proxy_authority, err)
|
format_err!("error connecting to {} - {}", proxy_authority, err)
|
||||||
})?;
|
})?;
|
||||||
@ -181,10 +182,13 @@ impl hyper::service::Service<Uri> for HttpsConnector {
|
|||||||
|
|
||||||
let mut connect_request = format!("CONNECT {0}:{1} HTTP/1.1\r\n", host, port);
|
let mut connect_request = format!("CONNECT {0}:{1} HTTP/1.1\r\n", host, port);
|
||||||
if let Some(authorization) = authorization {
|
if let Some(authorization) = authorization {
|
||||||
connect_request
|
let _ = write!(
|
||||||
.push_str(&format!("Proxy-Authorization: {}\r\n", authorization));
|
connect_request,
|
||||||
|
"Proxy-Authorization: {}\r\n",
|
||||||
|
authorization
|
||||||
|
);
|
||||||
}
|
}
|
||||||
connect_request.push_str(&format!("Host: {0}:{1}\r\n\r\n", host, port));
|
let _ = write!(connect_request, "Host: {0}:{1}\r\n\r\n", host, port);
|
||||||
|
|
||||||
tcp_stream.write_all(connect_request.as_bytes()).await?;
|
tcp_stream.write_all(connect_request.as_bytes()).await?;
|
||||||
tcp_stream.flush().await?;
|
tcp_stream.flush().await?;
|
||||||
|
@ -15,14 +15,16 @@ use super::{RateLimiter, ShareableRateLimit};
|
|||||||
|
|
||||||
type SharedRateLimit = Arc<dyn ShareableRateLimit>;
|
type SharedRateLimit = Arc<dyn ShareableRateLimit>;
|
||||||
|
|
||||||
|
pub type RateLimiterCallback =
|
||||||
|
dyn Fn() -> (Option<SharedRateLimit>, Option<SharedRateLimit>) + Send;
|
||||||
|
|
||||||
/// A rate limited stream using [RateLimiter]
|
/// A rate limited stream using [RateLimiter]
|
||||||
pub struct RateLimitedStream<S> {
|
pub struct RateLimitedStream<S> {
|
||||||
read_limiter: Option<SharedRateLimit>,
|
read_limiter: Option<SharedRateLimit>,
|
||||||
read_delay: Option<Pin<Box<Sleep>>>,
|
read_delay: Option<Pin<Box<Sleep>>>,
|
||||||
write_limiter: Option<SharedRateLimit>,
|
write_limiter: Option<SharedRateLimit>,
|
||||||
write_delay: Option<Pin<Box<Sleep>>>,
|
write_delay: Option<Pin<Box<Sleep>>>,
|
||||||
update_limiter_cb:
|
update_limiter_cb: Option<Box<RateLimiterCallback>>,
|
||||||
Option<Box<dyn Fn() -> (Option<SharedRateLimit>, Option<SharedRateLimit>) + Send>>,
|
|
||||||
last_limiter_update: Instant,
|
last_limiter_update: Instant,
|
||||||
stream: S,
|
stream: S,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user