Skip to content

refactor(proto/h1): simplify match version #3908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions src/proto/h1/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,15 +405,18 @@ impl Http1Transaction for Server {
{
extend(dst, b"HTTP/1.1 200 OK\r\n");
} else {
match msg.head.version {
Version::HTTP_10 => extend(dst, b"HTTP/1.0 "),
Version::HTTP_11 => extend(dst, b"HTTP/1.1 "),
Version::HTTP_2 => {
debug!("response with HTTP2 version coerced to HTTP/1.1");
extend(dst, b"HTTP/1.1 ");
}
other => panic!("unexpected response version: {:?}", other),
}
extend(
dst,
match msg.head.version {
Version::HTTP_10 => b"HTTP/1.0 ",
Version::HTTP_11 => b"HTTP/1.1 ",
Version::HTTP_2 => {
debug!("response with HTTP2 version coerced to HTTP/1.1");
b"HTTP/1.1 "
}
other => panic!("unexpected response version: {:?}", other),
},
);

extend(dst, msg.head.subject.as_str().as_bytes());
extend(dst, b" ");
Expand Down Expand Up @@ -1186,15 +1189,18 @@ impl Http1Transaction for Client {
//TODO: add API to http::Uri to encode without std::fmt
let _ = write!(FastWrite(dst), "{} ", msg.head.subject.1);

match msg.head.version {
Version::HTTP_10 => extend(dst, b"HTTP/1.0"),
Version::HTTP_11 => extend(dst, b"HTTP/1.1"),
Version::HTTP_2 => {
debug!("request with HTTP2 version coerced to HTTP/1.1");
extend(dst, b"HTTP/1.1");
}
other => panic!("unexpected request version: {:?}", other),
}
extend(
dst,
match msg.head.version {
Version::HTTP_10 => b"HTTP/1.0",
Version::HTTP_11 => b"HTTP/1.1",
Version::HTTP_2 => {
debug!("request with HTTP2 version coerced to HTTP/1.1");
b"HTTP/1.1"
}
other => panic!("unexpected request version: {:?}", other),
},
);
extend(dst, b"\r\n");

if let Some(orig_headers) = msg.head.extensions.get::<HeaderCaseMap>() {
Expand Down
Loading