Skip to content

Commit

Permalink
feat: options method return status 200
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden committed Jun 12, 2022
1 parent 471bca8 commit dd8b21f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl InnerService {
}
}
Method::OPTIONS => {
self.handle_method_options(&mut res);
self.handle_options(&mut res);
}
Method::PUT => {
if !allow_upload || (!allow_delete && is_file && size > 0) {
Expand Down Expand Up @@ -549,16 +549,14 @@ impl InnerService {
Ok(())
}

fn handle_method_options(&self, res: &mut Response) {
fn handle_options(&self, res: &mut Response) {
res.headers_mut().insert(
"Allow",
"GET,HEAD,PUT,OPTIONS,DELETE,PROPFIND,COPY,MOVE"
.parse()
.unwrap(),
);
res.headers_mut().insert("DAV", "1".parse().unwrap());

status!(res, StatusCode::NO_CONTENT);
}

async fn handle_propfind_dir(
Expand Down
2 changes: 1 addition & 1 deletion tests/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fn head_file_404(server: TestServer) -> Result<(), Error> {
#[rstest]
fn options_dir(server: TestServer) -> Result<(), Error> {
let resp = fetch!(b"OPTIONS", format!("{}index.html", server.url())).send()?;
assert_eq!(resp.status(), 204);
assert_eq!(resp.status(), 200);
assert_eq!(
resp.headers().get("allow").unwrap(),
"GET,HEAD,PUT,OPTIONS,DELETE,PROPFIND,COPY,MOVE"
Expand Down

0 comments on commit dd8b21f

Please sign in to comment.