feat(client): implement the HTTP/2 extended CONNECT protocol from RFC 8441 (#2682)

This commit is contained in:
Anthony Ramine
2022-02-08 02:35:34 +01:00
committed by GitHub
parent 6932896a7f
commit 5ec094caa5
7 changed files with 120 additions and 3 deletions

View File

@@ -14,6 +14,7 @@ use tracing::{debug, trace, warn};
use super::{ping, H2Upgraded, PipeToSendStream, SendBuf};
use crate::body::HttpBody;
use crate::common::{exec::Exec, task, Future, Never, Pin, Poll};
use crate::ext::Protocol;
use crate::headers;
use crate::proto::h2::UpgradedSendStream;
use crate::proto::Dispatched;
@@ -204,6 +205,15 @@ where
req_rx: ClientRx<B>,
}
impl<B> ClientTask<B>
where
B: HttpBody + 'static,
{
pub(crate) fn is_extended_connect_protocol_enabled(&self) -> bool {
self.h2_tx.is_extended_connect_protocol_enabled()
}
}
impl<B> Future for ClientTask<B>
where
B: HttpBody + Send + 'static,
@@ -260,6 +270,10 @@ where
}
}
if let Some(protocol) = req.extensions_mut().remove::<Protocol>() {
req.extensions_mut().insert(protocol.into_inner());
}
let (fut, body_tx) = match self.h2_tx.send_request(req, !is_connect && eos) {
Ok(ok) => ok,
Err(err) => {