Skip to content

Commit

Permalink
Ignore 107 error on front socket, add 100-continue case in e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Eloi DEMOLIS <[email protected]>
  • Loading branch information
Wonshtrum committed Jul 7, 2023
1 parent fc29354 commit c92d6bd
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 13 deletions.
30 changes: 29 additions & 1 deletion e2e/src/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,13 +878,41 @@ fn try_http_behaviors() -> State {
);

backend.set_response("HTTP/1.1 200 OK\r\n\r\n");
client.set_request("ping");
client.set_request("0123456789");
client.send();
let request = backend.receive(1).unwrap();
backend.send(1);

let expected_response_start = String::from("HTTP/1.1 200 OK\r\n");
let expected_response_end = String::from("\r\n\r\n");
let response = client.receive().unwrap();
println!("request: {request:?}");
println!("response: {response:?}");
assert!(
response.starts_with(&expected_response_start)
&& response.ends_with(&expected_response_end)
);
assert_eq!(request, String::from("0123"));


info!("expecting 100 BAD");
backend.set_response("HTTP/1.1 200 Ok\r\n\r\nRESPONSE_BODY_NO_LENGTH");
client.set_request("GET /100 HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\nExpect: 100-continue\r\n\r\n");
client.connect();
client.send();
backend.accept(1);
let request = backend.receive(1);
backend.send(1);

let expected_response_start = String::from("HTTP/1.1 200 Ok\r\n");
let expected_response_end = String::from("RESPONSE_BODY_NO_LENGTH");
let response = client.receive().unwrap();
println!("request: {request:?}");
println!("response: {response:?}");
assert!(
response.starts_with(&expected_response_start)
&& response.ends_with(&expected_response_end)
);

info!("expecting 103");
backend.set_response("HTTP/1.1 103 Early Hint\r\nLink: </style.css>; rel=preload; as=style\r\n\r\nHTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\npong");
Expand Down
11 changes: 7 additions & 4 deletions lib/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,13 @@ impl ProxySession for HttpSession {

let front_socket = self.state.front_socket();
if let Err(e) = front_socket.shutdown(Shutdown::Both) {
error!(
"error shutting down front socket({:?}): {:?}",
front_socket, e
)
// error 107 NotConnected can happen when was never fully connected, or was already disconnected due to error
if e.kind() != ErrorKind::NotConnected {
error!(
"error shutting down front socket({:?}): {:?}",
front_socket, e
)
}
}

// deregister the frontend and remove it
Expand Down
11 changes: 7 additions & 4 deletions lib/src/https.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,13 @@ impl ProxySession for HttpsSession {

let front_socket = self.state.front_socket();
if let Err(e) = front_socket.shutdown(Shutdown::Both) {
error!(
"error shutting down front socket({:?}): {:?}",
front_socket, e
);
// error 107 NotConnected can happen when was never fully connected, or was already disconnected due to error
if e.kind() != ErrorKind::NotConnected {
error!(
"error shutting down front socket({:?}): {:?}",
front_socket, e
);
}
}

// deregister the frontend and remove it
Expand Down
11 changes: 7 additions & 4 deletions lib/src/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,10 +928,13 @@ impl ProxySession for TcpSession {

let front_socket = self.state.front_socket();
if let Err(e) = front_socket.shutdown(Shutdown::Both) {
error!(
"error shutting down front socket({:?}): {:?}",
front_socket, e
);
// error 107 NotConnected can happen when was never fully connected, or was already disconnected due to error
if e.kind() != ErrorKind::NotConnected {
error!(
"error shutting down front socket({:?}): {:?}",
front_socket, e
);
}
}

// deregister the frontend and remove it, in a separate scope to drop proxy when done
Expand Down

0 comments on commit c92d6bd

Please sign in to comment.