feat: options method return status 200
This commit is contained in:
parent
471bca86c6
commit
dd8b21f3a6
2 changed files with 3 additions and 5 deletions
|
@ -210,7 +210,7 @@ impl InnerService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Method::OPTIONS => {
|
Method::OPTIONS => {
|
||||||
self.handle_method_options(&mut res);
|
self.handle_options(&mut res);
|
||||||
}
|
}
|
||||||
Method::PUT => {
|
Method::PUT => {
|
||||||
if !allow_upload || (!allow_delete && is_file && size > 0) {
|
if !allow_upload || (!allow_delete && is_file && size > 0) {
|
||||||
|
@ -549,7 +549,7 @@ impl InnerService {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_method_options(&self, res: &mut Response) {
|
fn handle_options(&self, res: &mut Response) {
|
||||||
res.headers_mut().insert(
|
res.headers_mut().insert(
|
||||||
"Allow",
|
"Allow",
|
||||||
"GET,HEAD,PUT,OPTIONS,DELETE,PROPFIND,COPY,MOVE"
|
"GET,HEAD,PUT,OPTIONS,DELETE,PROPFIND,COPY,MOVE"
|
||||||
|
@ -557,8 +557,6 @@ impl InnerService {
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
res.headers_mut().insert("DAV", "1".parse().unwrap());
|
res.headers_mut().insert("DAV", "1".parse().unwrap());
|
||||||
|
|
||||||
status!(res, StatusCode::NO_CONTENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_propfind_dir(
|
async fn handle_propfind_dir(
|
||||||
|
|
|
@ -129,7 +129,7 @@ fn head_file_404(server: TestServer) -> Result<(), Error> {
|
||||||
#[rstest]
|
#[rstest]
|
||||||
fn options_dir(server: TestServer) -> Result<(), Error> {
|
fn options_dir(server: TestServer) -> Result<(), Error> {
|
||||||
let resp = fetch!(b"OPTIONS", format!("{}index.html", server.url())).send()?;
|
let resp = fetch!(b"OPTIONS", format!("{}index.html", server.url())).send()?;
|
||||||
assert_eq!(resp.status(), 204);
|
assert_eq!(resp.status(), 200);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resp.headers().get("allow").unwrap(),
|
resp.headers().get("allow").unwrap(),
|
||||||
"GET,HEAD,PUT,OPTIONS,DELETE,PROPFIND,COPY,MOVE"
|
"GET,HEAD,PUT,OPTIONS,DELETE,PROPFIND,COPY,MOVE"
|
||||||
|
|
Loading…
Reference in a new issue