From 520171f17ae9d6aa9f2af3f61f04397dfd5864de Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Thu, 11 Jan 2024 14:15:20 +0000 Subject: [PATCH] ws over http2 --- proxy/src/serverless.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/proxy/src/serverless.rs b/proxy/src/serverless.rs index 4fea2fec94..2f632ec8da 100644 --- a/proxy/src/serverless.rs +++ b/proxy/src/serverless.rs @@ -8,7 +8,9 @@ mod websocket; pub use conn_pool::GlobalConnPoolOptions; -use anyhow::bail; +use anyhow::{bail, Context}; +use hyper::ext::Protocol; +use hyper::upgrade::OnUpgrade; use hyper::StatusCode; use metrics::IntCounterPairGuard; use rand::rngs::StdRng; @@ -154,6 +156,7 @@ pub async fn task_main( ); hyper::Server::builder(accept::from_stream(tls_listener)) + .http2_enable_connect_protocol() .serve(make_svc) .with_graceful_shutdown(cancellation_token.cancelled()) .await?; @@ -246,6 +249,25 @@ async fn request_handler( // Return the response so the spawned future can continue. Ok(response) + } else if request.method() == Method::CONNECT { + // request. + dbg!(request.headers()); + let _upgrade = request + .extensions_mut() + .remove::() + .context("missing upgrade") + .map_err(ApiError::InternalServerError)?; + let protocol = request + .extensions_mut() + .remove::() + .context("missing protocol") + .map_err(ApiError::InternalServerError)?; + + tracing::info!(protocol = protocol.as_str(), "http2 connect???"); + + Err(ApiError::InternalServerError(anyhow::anyhow!( + "not yet supported" + ))) } else if request.uri().path() == "/sql" && request.method() == Method::POST { let mut ctx = RequestMonitoring::new(session_id, peer_addr, "http", &config.region);