Don't override empty path for CONNECT requests (#534)

This commit is contained in:
Anthony Ramine
2021-04-28 03:55:46 +02:00
committed by GitHub
parent 35699e721a
commit 10d17e5f62
2 changed files with 8 additions and 4 deletions

View File

@@ -552,15 +552,19 @@ impl Pseudo {
.map(|v| Bytes::copy_from_slice(v.as_str().as_bytes()))
.unwrap_or_else(Bytes::new);
if path.is_empty() && method != Method::OPTIONS {
path = Bytes::from_static(b"/");
match method {
Method::OPTIONS | Method::CONNECT => {}
_ if path.is_empty() => {
path = Bytes::from_static(b"/");
}
_ => {}
}
let mut pseudo = Pseudo {
method: Some(method),
scheme: None,
authority: None,
path: Some(unsafe { BytesStr::from_utf8_unchecked(path) }),
path: Some(unsafe { BytesStr::from_utf8_unchecked(path) }).filter(|p| !p.is_empty()),
status: None,
};

View File

@@ -114,7 +114,7 @@ async fn serve_connect() {
let settings = client.assert_server_handshake().await;
assert_default_settings!(settings);
client
.send_frame(frames::headers(1).method("CONNECT").eos())
.send_frame(frames::headers(1).request("CONNECT", "localhost").eos())
.await;
client
.recv_frame(frames::headers(1).response(200).eos())