mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-08-03 17:22:15 +00:00
hyper: start preparing upgrade to 1.x
by switching on deprecations and using some backported types already available on 0.14: - use body::HttpBody::collect() instead of to_bytes() directly on Body - use server::conn::http2::Builder instead of server::conn::Http with http2_only Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
168ed37026
commit
6565199af4
@ -127,7 +127,7 @@ futures = "0.3"
|
||||
h2 = { version = "0.4", features = [ "legacy", "stream" ] }
|
||||
handlebars = "3.0"
|
||||
hex = "0.4.3"
|
||||
hyper = { version = "0.14", features = [ "full" ] }
|
||||
hyper = { version = "0.14", features = [ "backports", "deprecated", "full" ] }
|
||||
libc = "0.2"
|
||||
log = "0.4.17"
|
||||
nix = "0.26.1"
|
||||
|
@ -8,7 +8,7 @@ use hyper::client::{Client, HttpConnector};
|
||||
use hyper::http::header::HeaderValue;
|
||||
use hyper::http::Uri;
|
||||
use hyper::http::{Request, Response};
|
||||
use hyper::Body;
|
||||
use hyper::{body::HttpBody, Body};
|
||||
use openssl::{
|
||||
ssl::{SslConnector, SslMethod},
|
||||
x509::X509StoreContextRef,
|
||||
@ -706,8 +706,7 @@ impl HttpClient {
|
||||
.map(|_| Err(format_err!("unknown error")))
|
||||
.await?
|
||||
} else {
|
||||
resp.into_body()
|
||||
.map_err(Error::from)
|
||||
futures::TryStreamExt::map_err(resp.into_body(), Error::from)
|
||||
.try_fold(output, move |acc, chunk| async move {
|
||||
acc.write_all(&chunk)?;
|
||||
Ok::<_, Error>(acc)
|
||||
@ -844,7 +843,7 @@ impl HttpClient {
|
||||
|
||||
async fn api_response(response: Response<Body>) -> Result<Value, Error> {
|
||||
let status = response.status();
|
||||
let data = hyper::body::to_bytes(response.into_body()).await?;
|
||||
let data = HttpBody::collect(response.into_body()).await?.to_bytes();
|
||||
|
||||
let text = String::from_utf8(data.to_vec()).unwrap();
|
||||
if status.is_success() {
|
||||
|
@ -7,7 +7,7 @@ use hyper::client::connect::{Connected, Connection};
|
||||
use hyper::client::Client;
|
||||
use hyper::http::Uri;
|
||||
use hyper::http::{Request, Response};
|
||||
use hyper::Body;
|
||||
use hyper::{body::HttpBody, Body};
|
||||
use pin_project_lite::pin_project;
|
||||
use serde_json::Value;
|
||||
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, ReadBuf};
|
||||
@ -179,8 +179,7 @@ impl VsockClient {
|
||||
if !status.is_success() {
|
||||
Self::api_response(resp).await.map(|_| ())?
|
||||
} else {
|
||||
resp.into_body()
|
||||
.map_err(Error::from)
|
||||
futures::TryStreamExt::map_err(resp.into_body(), Error::from)
|
||||
.try_fold(output, move |acc, chunk| async move {
|
||||
acc.write_all(&chunk).await?;
|
||||
Ok::<_, Error>(acc)
|
||||
@ -192,7 +191,7 @@ impl VsockClient {
|
||||
|
||||
async fn api_response(response: Response<Body>) -> Result<Value, Error> {
|
||||
let status = response.status();
|
||||
let data = hyper::body::to_bytes(response.into_body()).await?;
|
||||
let data = HttpBody::collect(response.into_body()).await?.to_bytes();
|
||||
|
||||
let text = String::from_utf8(data.to_vec()).unwrap();
|
||||
if status.is_success() {
|
||||
|
@ -6,7 +6,7 @@ use std::os::unix::fs::OpenOptionsExt;
|
||||
|
||||
use anyhow::{bail, format_err};
|
||||
use bytes::Bytes;
|
||||
use hyper::{Body, Request};
|
||||
use hyper::{body::HttpBody, Body, Request};
|
||||
use nix::sys::stat::Mode;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -508,9 +508,11 @@ impl AcmeClient {
|
||||
let (parts, body) = response.into_parts();
|
||||
|
||||
let status = parts.status.as_u16();
|
||||
let body = hyper::body::to_bytes(body)
|
||||
let body = body
|
||||
.collect()
|
||||
.await
|
||||
.map_err(|err| Error::Custom(format!("failed to retrieve response body: {}", err)))?;
|
||||
.map_err(|err| Error::Custom(format!("failed to retrieve response body: {}", err)))?
|
||||
.to_bytes();
|
||||
|
||||
let got_nonce = if let Some(new_nonce) = parts.headers.get(proxmox_acme::REPLAY_NONCE) {
|
||||
let new_nonce = new_nonce.to_str().map_err(|err| {
|
||||
|
@ -239,14 +239,12 @@ fn upgrade_to_backup_protocol(
|
||||
.and_then(move |conn| {
|
||||
env2.debug("protocol upgrade done");
|
||||
|
||||
let mut http = hyper::server::conn::Http::new()
|
||||
.with_executor(ExecInheritLogContext);
|
||||
http.http2_only(true);
|
||||
let mut http = hyper::server::conn::http2::Builder::new(ExecInheritLogContext);
|
||||
// increase window size: todo - find optiomal size
|
||||
let window_size = 32 * 1024 * 1024; // max = (1 << 31) - 2
|
||||
http.http2_initial_stream_window_size(window_size);
|
||||
http.http2_initial_connection_window_size(window_size);
|
||||
http.http2_max_frame_size(4 * 1024 * 1024);
|
||||
http.initial_stream_window_size(window_size);
|
||||
http.initial_connection_window_size(window_size);
|
||||
http.max_frame_size(4 * 1024 * 1024);
|
||||
|
||||
let env3 = env2.clone();
|
||||
http.serve_connection(conn, service).map(move |result| {
|
||||
|
@ -183,14 +183,12 @@ fn upgrade_to_backup_reader_protocol(
|
||||
let conn = hyper::upgrade::on(Request::from_parts(parts, req_body)).await?;
|
||||
env2.debug("protocol upgrade done");
|
||||
|
||||
let mut http =
|
||||
hyper::server::conn::Http::new().with_executor(ExecInheritLogContext);
|
||||
http.http2_only(true);
|
||||
let mut http = hyper::server::conn::http2::Builder::new(ExecInheritLogContext);
|
||||
// increase window size: todo - find optiomal size
|
||||
let window_size = 32 * 1024 * 1024; // max = (1 << 31) - 2
|
||||
http.http2_initial_stream_window_size(window_size);
|
||||
http.http2_initial_connection_window_size(window_size);
|
||||
http.http2_max_frame_size(4 * 1024 * 1024);
|
||||
http.initial_stream_window_size(window_size);
|
||||
http.initial_connection_window_size(window_size);
|
||||
http.max_frame_size(4 * 1024 * 1024);
|
||||
|
||||
http.serve_connection(conn, service)
|
||||
.map_err(Error::from)
|
||||
|
Loading…
Reference in New Issue
Block a user