Downgrade I/O stream closing to warning.

Since active I/O streams will be closed by graceful shutdown, an error,
as was previously emitted, was necessarily alarmist. This reduces the
severity of the log message to a warning.
This commit is contained in:
Sergio Benitez 2023-03-30 12:46:34 -07:00
parent bd482081ad
commit 2a63b1a41f
1 changed files with 8 additions and 4 deletions

View File

@ -173,22 +173,26 @@ impl Rocket<Orbit> {
async fn handle_upgrade<'r>(
&self,
mut response: Response<'r>,
protocol: uncased::Uncased<'r>,
proto: uncased::Uncased<'r>,
mut io_handler: Box<dyn IoHandler + 'r>,
pending_upgrade: hyper::upgrade::OnUpgrade,
tx: oneshot::Sender<hyper::Response<hyper::Body>>,
) {
info_!("Upgrading connection to {}.", Paint::white(&protocol));
info_!("Upgrading connection to {}.", Paint::white(&proto).bold());
response.set_status(Status::SwitchingProtocols);
response.set_raw_header("Connection", "Upgrade");
response.set_raw_header("Upgrade", protocol.into_cow());
response.set_raw_header("Upgrade", proto.clone().into_cow());
self.send_response(response, tx).await;
match pending_upgrade.await {
Ok(io_stream) => {
info_!("Upgrade successful.");
if let Err(e) = io_handler.io(io_stream.into()).await {
error!("Upgraded I/O handler failed: {}", e);
if e.kind() == io::ErrorKind::BrokenPipe {
warn!("Upgraded {} I/O handler was closed.", proto);
} else {
error!("Upgraded {} I/O handler failed: {}", proto, e);
}
}
},
Err(e) => {