mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
Fix Allow header in OPTION method
This commit is contained in:
@@ -3,7 +3,7 @@ use actix_web::{
|
||||
dev::{HttpServiceFactory, ServiceResponse},
|
||||
http::{
|
||||
Method, StatusCode,
|
||||
header::{HeaderName, HeaderValue},
|
||||
header::{self, HeaderName, HeaderValue},
|
||||
},
|
||||
middleware::{ErrorHandlerResponse, ErrorHandlers},
|
||||
web::{self, Data},
|
||||
@@ -36,16 +36,20 @@ pub fn carddav_service<AP: AuthenticationProvider, A: AddressbookStore, S: Subsc
|
||||
ErrorHandlers::new().handler(StatusCode::METHOD_NOT_ALLOWED, |res| {
|
||||
Ok(ErrorHandlerResponse::Response(
|
||||
if res.request().method() == Method::OPTIONS {
|
||||
let response = HttpResponse::Ok()
|
||||
.insert_header((
|
||||
HeaderName::from_static("dav"),
|
||||
// https://datatracker.ietf.org/doc/html/rfc4918#section-18
|
||||
HeaderValue::from_static(
|
||||
"1, 3, access-control, addressbook, extended-mkcol",
|
||||
),
|
||||
))
|
||||
.finish();
|
||||
ServiceResponse::new(res.into_parts().0, response).map_into_right_body()
|
||||
let mut response = HttpResponse::Ok();
|
||||
response.insert_header((
|
||||
HeaderName::from_static("dav"),
|
||||
// https://datatracker.ietf.org/doc/html/rfc4918#section-18
|
||||
HeaderValue::from_static(
|
||||
"1, 3, access-control, addressbook, extended-mkcol",
|
||||
),
|
||||
));
|
||||
|
||||
if let Some(allow) = res.headers().get(header::ALLOW) {
|
||||
response.insert_header((header::ALLOW, allow.to_owned()));
|
||||
}
|
||||
ServiceResponse::new(res.into_parts().0, response.finish())
|
||||
.map_into_right_body()
|
||||
} else {
|
||||
res.map_into_left_body()
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user