Skip to content

Commit

Permalink
Server: remove default body setting behavior for errors
Browse files Browse the repository at this point in the history
This is probably never what a Tide user wants.

The developer of a server can use the log middleware, otherwise this presents a risk as it may point to potentially exploitable flaws.

Additionally, Tide can't completely aguarentee this will be in an expected format.
  • Loading branch information
Fishrock123 committed Jun 22, 2020
1 parent f59935f commit d5e4e66
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,21 +428,7 @@ impl<State: Send + Sync + 'static> Server<State> {
};

let res = next.run(req).await;
let mut res: http_types::Response = res.into();

if res.len().is_some() {
return Ok(res.into());
}

if let Some(err) = res.error() {
// Only send the message if it is a non-500 range error. All
// errors default to 500 by default, so sending the error
// body is opt-in at the call site.
if !err.status().is_server_error() {
let msg = err.to_string();
res.set_body(msg);
}
}
let res: http_types::Response = res.into();
Ok(res.into())
}
}
Expand Down

0 comments on commit d5e4e66

Please sign in to comment.