refactor: change the format of www-authenticate (#312)

This commit is contained in:
sigoden
2023-12-07 15:04:14 +08:00
committed by GitHub
parent 5c850256f4
commit 37800f630d
3 changed files with 28 additions and 17 deletions

View File

@@ -21,7 +21,7 @@ use headers::{
};
use hyper::header::{
HeaderValue, AUTHORIZATION, CONTENT_DISPOSITION, CONTENT_LENGTH, CONTENT_RANGE, CONTENT_TYPE,
RANGE, WWW_AUTHENTICATE,
RANGE,
};
use hyper::{Body, Method, StatusCode, Uri};
use serde::Serialize;
@@ -1056,9 +1056,8 @@ impl Server {
fn auth_reject(&self, res: &mut Response) -> Result<()> {
set_webdav_headers(res);
res.headers_mut()
.append(WWW_AUTHENTICATE, www_authenticate(&self.args)?);
// set 401 to make the browser pop up the login box
www_authenticate(res, &self.args)?;
*res.status_mut() = StatusCode::UNAUTHORIZED;
Ok(())
}