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 2b6329a commit 6232082
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ntex/src/http/h1/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,29 +398,29 @@ 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() {
if i >= S_CLOSE.len() {
return None;

Check warning on line 402 in ntex/src/http/h1/decoder.rs

View check run for this annotation

Codecov / codecov/patch

ntex/src/http/h1/decoder.rs#L402

Added line #L402 was not covered by tests
}
let result = match bytes[i] {
b'k' | b'K' => {
let pos = i + S_KEEP_ALIVE.len();
if l > pos && 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

Check warning on line 410 in ntex/src/http/h1/decoder.rs

View check run for this annotation

Codecov / codecov/patch

ntex/src/http/h1/decoder.rs#L410

Added line #L410 was not covered by tests
}
}
b'c' | b'C' => {
let pos = i + S_CLOSE.len();
if l > pos && 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

Check warning on line 418 in ntex/src/http/h1/decoder.rs

View check run for this annotation

Codecov / codecov/patch

ntex/src/http/h1/decoder.rs#L418

Added line #L418 was not covered by tests
}
}
b'u' | b'U' => {
let pos = i + S_UPGRADE.len();
if l > pos && 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

Check warning on line 426 in ntex/src/http/h1/decoder.rs

View check run for this annotation

Codecov / codecov/patch

ntex/src/http/h1/decoder.rs#L426

Added line #L426 was not covered by tests
Expand All @@ -432,7 +432,7 @@ fn connection_type(val: &str) -> Option<ConnectionType> {
if let Some((t, pos)) = result {
let next = pos + 1;
if val.len() > next {
if matches!(bytes[next], b' ' | b',') {
if matches!(bytes[next], b' ' | b',' | b'\r' | b'\n') {
return Some(t);
}

Check warning on line 437 in ntex/src/http/h1/decoder.rs

View check run for this annotation

Codecov / codecov/patch

ntex/src/http/h1/decoder.rs#L435-L437

Added lines #L435 - L437 were not covered by tests
} else {
Expand Down

0 comments on commit 6232082

Please sign in to comment.