mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-10-04 11:22:56 +00:00
examples: h2server: port to http2::Builder::new
Fixes the deprecation warning while building this example. Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
This commit is contained in:
parent
6565199af4
commit
7085d270d4
@ -1,9 +1,24 @@
|
|||||||
|
use std::future::Future;
|
||||||
|
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use futures::*;
|
use futures::*;
|
||||||
use hyper::{Body, Request, Response};
|
use hyper::{Body, Request, Response};
|
||||||
|
|
||||||
use tokio::net::{TcpListener, TcpStream};
|
use tokio::net::{TcpListener, TcpStream};
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
struct H2Executor;
|
||||||
|
|
||||||
|
impl<Fut> hyper::rt::Executor<Fut> for H2Executor
|
||||||
|
where
|
||||||
|
Fut: Future + Send + 'static,
|
||||||
|
Fut::Output: Send,
|
||||||
|
{
|
||||||
|
fn execute(&self, fut: Fut) {
|
||||||
|
tokio::spawn(fut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), Error> {
|
fn main() -> Result<(), Error> {
|
||||||
proxmox_async::runtime::main(run())
|
proxmox_async::runtime::main(run())
|
||||||
}
|
}
|
||||||
@ -26,12 +41,11 @@ async fn run() -> Result<(), Error> {
|
|||||||
async fn handle_connection(socket: TcpStream) -> Result<(), Error> {
|
async fn handle_connection(socket: TcpStream) -> Result<(), Error> {
|
||||||
socket.set_nodelay(true).unwrap();
|
socket.set_nodelay(true).unwrap();
|
||||||
|
|
||||||
let mut http = hyper::server::conn::Http::new();
|
let mut http = hyper::server::conn::http2::Builder::new(H2Executor);
|
||||||
http.http2_only(true);
|
|
||||||
// increase window size: todo - find optiomal size
|
// increase window size: todo - find optiomal size
|
||||||
let max_window_size = (1 << 31) - 2;
|
let max_window_size = (1 << 31) - 2;
|
||||||
http.http2_initial_stream_window_size(max_window_size);
|
http.initial_stream_window_size(max_window_size);
|
||||||
http.http2_initial_connection_window_size(max_window_size);
|
http.initial_connection_window_size(max_window_size);
|
||||||
|
|
||||||
let service = hyper::service::service_fn(|_req: Request<Body>| {
|
let service = hyper::service::service_fn(|_req: Request<Body>| {
|
||||||
println!("Got request");
|
println!("Got request");
|
||||||
|
Loading…
Reference in New Issue
Block a user