Fix bug where autorewrite was always on, respond 50 and log instead of panic on rewrite error
This commit is contained in:
parent
680c04abe4
commit
9bc1f317c5
26
src/lib.rs
26
src/lib.rs
|
@ -390,6 +390,7 @@ impl ServerInner {
|
|||
request.set_cert(client_cert);
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "gemini_srv", allow(unused_mut))] // Used for scgi_srv only
|
||||
let mut response = if let Some((trailing, handler)) = self.routes.match_request(&request) {
|
||||
request.set_trailing(trailing);
|
||||
handler.handle(request.clone()).await
|
||||
|
@ -397,12 +398,25 @@ impl ServerInner {
|
|||
Response::not_found()
|
||||
};
|
||||
|
||||
match response.rewrite_all(&request).await {
|
||||
Ok(true) => { /* all is well */ }
|
||||
Ok(false) => panic!("Upstream did not include SCRIPT_PATH or SCRIPT_NAME"),
|
||||
Err(e) => {
|
||||
error!("Error reading text/gemini file from Response reader: {}", e);
|
||||
response = Response::not_found();
|
||||
#[cfg(feature = "scgi_srv")] // No point running noop code
|
||||
if self.autorewrite {
|
||||
match response.rewrite_all(&request).await {
|
||||
Ok(true) => { /* all is well */ }
|
||||
Ok(false) => {
|
||||
error!(
|
||||
concat!(
|
||||
"Upstream did not include SCRIPT_PATH or SCRIPT_NAME, refusing to",
|
||||
" serve any text/gemini content with absolute links. It's most",
|
||||
" likely that the proxy server you're using doesn't correctly",
|
||||
" or completely implement the SCGI specification.",
|
||||
)
|
||||
);
|
||||
response = Response::temporary_failure("Server misconfigured");
|
||||
},
|
||||
Err(e) => {
|
||||
error!("Error reading text/gemini file from Response reader: {}", e);
|
||||
response = Response::not_found();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue