mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-28 01:52:57 +01:00
better connect handling
This commit is contained in:
parent
ddd9c24bb2
commit
f1e82ebc1e
10
src/h1.rs
10
src/h1.rs
@ -581,7 +581,9 @@ impl Reader {
|
|||||||
msg
|
msg
|
||||||
};
|
};
|
||||||
|
|
||||||
let decoder = if let Some(len) = msg.get_ref().headers.get(header::CONTENT_LENGTH) {
|
let decoder = if msg.get_ref().method == Method::CONNECT {
|
||||||
|
Some(Decoder::eof())
|
||||||
|
} else if let Some(len) = msg.get_ref().headers.get(header::CONTENT_LENGTH) {
|
||||||
// Content-Length
|
// Content-Length
|
||||||
if let Ok(s) = len.to_str() {
|
if let Ok(s) = len.to_str() {
|
||||||
if let Ok(len) = s.parse::<u64>() {
|
if let Ok(len) = s.parse::<u64>() {
|
||||||
@ -597,9 +599,7 @@ impl Reader {
|
|||||||
} else if chunked(&msg.get_mut().headers)? {
|
} else if chunked(&msg.get_mut().headers)? {
|
||||||
// Chunked encoding
|
// Chunked encoding
|
||||||
Some(Decoder::chunked())
|
Some(Decoder::chunked())
|
||||||
} else if msg.get_ref().headers.contains_key(header::UPGRADE) ||
|
} else if msg.get_ref().headers.contains_key(header::UPGRADE) {
|
||||||
msg.get_ref().method == Method::CONNECT
|
|
||||||
{
|
|
||||||
Some(Decoder::eof())
|
Some(Decoder::eof())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -1215,6 +1215,7 @@ mod tests {
|
|||||||
fn test_conn_upgrade() {
|
fn test_conn_upgrade() {
|
||||||
let mut buf = Buffer::new(
|
let mut buf = Buffer::new(
|
||||||
"GET /test HTTP/1.1\r\n\
|
"GET /test HTTP/1.1\r\n\
|
||||||
|
upgrade: websockets\r\n\
|
||||||
connection: upgrade\r\n\r\n");
|
connection: upgrade\r\n\r\n");
|
||||||
let req = parse_ready!(&mut buf);
|
let req = parse_ready!(&mut buf);
|
||||||
|
|
||||||
@ -1226,6 +1227,7 @@ mod tests {
|
|||||||
fn test_conn_upgrade_connect_method() {
|
fn test_conn_upgrade_connect_method() {
|
||||||
let mut buf = Buffer::new(
|
let mut buf = Buffer::new(
|
||||||
"CONNECT /test HTTP/1.1\r\n\
|
"CONNECT /test HTTP/1.1\r\n\
|
||||||
|
upgrade: websockets\r\n\
|
||||||
content-length: 0\r\n\r\n");
|
content-length: 0\r\n\r\n");
|
||||||
let req = parse_ready!(&mut buf);
|
let req = parse_ready!(&mut buf);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user