From dd8b21f3a6d056b86000868c8145876e4a271104 Mon Sep 17 00:00:00 2001 From: sigoden Date: Sun, 12 Jun 2022 09:33:01 +0800 Subject: [PATCH] feat: options method return status 200 --- src/server.rs | 6 ++---- tests/http.rs | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/server.rs b/src/server.rs index b89f7c76a..966537464 100644 --- a/src/server.rs +++ b/src/server.rs @@ -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) { @@ -549,7 +549,7 @@ 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" @@ -557,8 +557,6 @@ impl InnerService { .unwrap(), ); res.headers_mut().insert("DAV", "1".parse().unwrap()); - - status!(res, StatusCode::NO_CONTENT); } async fn handle_propfind_dir( diff --git a/tests/http.rs b/tests/http.rs index d8a884704..0d7d3e1e1 100644 --- a/tests/http.rs +++ b/tests/http.rs @@ -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"