mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-05 13:57:39 +03:00
wip
This commit is contained in:
parent
82742ead1a
commit
81c0779be7
1 changed files with 7 additions and 3 deletions
|
@ -395,12 +395,16 @@ const S_CLOSE: &str = "close";
|
||||||
const S_UPGRADE: &str = "upgrade";
|
const S_UPGRADE: &str = "upgrade";
|
||||||
|
|
||||||
fn connection_type(val: &str) -> Option<ConnectionType> {
|
fn connection_type(val: &str) -> Option<ConnectionType> {
|
||||||
|
let l = val.len();
|
||||||
let bytes = val.as_bytes();
|
let bytes = val.as_bytes();
|
||||||
for i in 0..bytes.len() {
|
for i in 0..bytes.len() {
|
||||||
|
if i <= S_CLOSE.len() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
let result = match bytes[i] {
|
let result = match bytes[i] {
|
||||||
b'k' | b'K' => {
|
b'k' | b'K' => {
|
||||||
let pos = i + S_KEEP_ALIVE.len();
|
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))
|
Some((ConnectionType::KeepAlive, pos))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -408,7 +412,7 @@ fn connection_type(val: &str) -> Option<ConnectionType> {
|
||||||
}
|
}
|
||||||
b'c' | b'C' => {
|
b'c' | b'C' => {
|
||||||
let pos = i + S_CLOSE.len();
|
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))
|
Some((ConnectionType::Close, pos))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -416,7 +420,7 @@ fn connection_type(val: &str) -> Option<ConnectionType> {
|
||||||
}
|
}
|
||||||
b'u' | b'U' => {
|
b'u' | b'U' => {
|
||||||
let pos = i + S_UPGRADE.len();
|
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))
|
Some((ConnectionType::Upgrade, pos))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue