Skip to content

Commit

Permalink
Server: remove default body 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 Jul 7, 2020
1 parent 92760bb commit 368855d
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,22 +427,7 @@ impl<State: Send + Sync + 'static> Server<State> {
next_middleware: &middleware,
};

let mut res = next.run(req).await;
if res.len().is_some() {
let res: http_types::Response = res.into();
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 = next.run(req).await;
let res: http_types::Response = res.into();
Ok(res.into())
}
Expand Down

0 comments on commit 368855d

Please sign in to comment.