Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Jun 22, 2024
1 parent 82742ea commit 81c0779
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ntex/src/http/h1/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,28 +395,32 @@ const S_CLOSE: &str = "close";
const S_UPGRADE: &str = "upgrade";

fn connection_type(val: &str) -> Option<ConnectionType> {
let l = val.len();
let bytes = val.as_bytes();
for i in 0..bytes.len() {
if i <= S_CLOSE.len() {
return None;
}
let result = match bytes[i] {
b'k' | b'K' => {
let pos = i + S_KEEP_ALIVE.len();
if val[i..pos].eq_ignore_ascii_case(S_KEEP_ALIVE) {
if l > pos && val[i..pos].eq_ignore_ascii_case(S_KEEP_ALIVE) {
Some((ConnectionType::KeepAlive, pos))
} else {
None
}
}
b'c' | b'C' => {
let pos = i + S_CLOSE.len();
if val[i..pos].eq_ignore_ascii_case(S_CLOSE) {
if l > pos && val[i..pos].eq_ignore_ascii_case(S_CLOSE) {
Some((ConnectionType::Close, pos))
} else {
None
}
}
b'u' | b'U' => {
let pos = i + S_UPGRADE.len();
if val[i..pos].eq_ignore_ascii_case(S_UPGRADE) {
if l > pos && val[i..pos].eq_ignore_ascii_case(S_UPGRADE) {
Some((ConnectionType::Upgrade, pos))
} else {
None
Expand Down

0 comments on commit 81c0779

Please sign in to comment.