Compare commits

..

6 Commits

Author SHA1 Message Date
Lennart
e69c75102c version 0.6.4 2025-07-22 10:55:28 +02:00
Lennart
09f1bd20ae close connection if request body might not have been consumed
hopefully fixes #77
2025-07-22 10:53:12 +02:00
Lennart
72f970a857 version 0.6.3 2025-07-20 13:39:25 +02:00
Lennart
08c250657e well-known: add second apple user agent 2025-07-20 13:38:57 +02:00
Lennart
b8ef2f1ba2 version 0.6.2 2025-07-20 13:16:42 +02:00
Lennart
c8adf60f48 version 0.6.1 2025-07-20 13:13:01 +02:00
3 changed files with 33 additions and 14 deletions

22
Cargo.lock generated
View File

@@ -2999,7 +2999,7 @@ dependencies = [
[[package]] [[package]]
name = "rustical" name = "rustical"
version = "0.6.0" version = "0.6.4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"argon2", "argon2",
@@ -3042,7 +3042,7 @@ dependencies = [
[[package]] [[package]]
name = "rustical_caldav" name = "rustical_caldav"
version = "0.6.0" version = "0.6.4"
dependencies = [ dependencies = [
"async-std", "async-std",
"async-trait", "async-trait",
@@ -3080,7 +3080,7 @@ dependencies = [
[[package]] [[package]]
name = "rustical_carddav" name = "rustical_carddav"
version = "0.6.0" version = "0.6.4"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"axum", "axum",
@@ -3112,7 +3112,7 @@ dependencies = [
[[package]] [[package]]
name = "rustical_dav" name = "rustical_dav"
version = "0.6.0" version = "0.6.4"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"axum", "axum",
@@ -3137,7 +3137,7 @@ dependencies = [
[[package]] [[package]]
name = "rustical_dav_push" name = "rustical_dav_push"
version = "0.6.0" version = "0.6.4"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"axum", "axum",
@@ -3163,7 +3163,7 @@ dependencies = [
[[package]] [[package]]
name = "rustical_frontend" name = "rustical_frontend"
version = "0.6.0" version = "0.6.4"
dependencies = [ dependencies = [
"askama", "askama",
"askama_web", "askama_web",
@@ -3196,7 +3196,7 @@ dependencies = [
[[package]] [[package]]
name = "rustical_ical" name = "rustical_ical"
version = "0.6.0" version = "0.6.4"
dependencies = [ dependencies = [
"axum", "axum",
"chrono", "chrono",
@@ -3214,7 +3214,7 @@ dependencies = [
[[package]] [[package]]
name = "rustical_oidc" name = "rustical_oidc"
version = "0.6.0" version = "0.6.4"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"axum", "axum",
@@ -3229,7 +3229,7 @@ dependencies = [
[[package]] [[package]]
name = "rustical_store" name = "rustical_store"
version = "0.6.0" version = "0.6.4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@@ -3263,7 +3263,7 @@ dependencies = [
[[package]] [[package]]
name = "rustical_store_sqlite" name = "rustical_store_sqlite"
version = "0.6.0" version = "0.6.4"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"chrono", "chrono",
@@ -3284,7 +3284,7 @@ dependencies = [
[[package]] [[package]]
name = "rustical_xml" name = "rustical_xml"
version = "0.6.0" version = "0.6.4"
dependencies = [ dependencies = [
"quick-xml", "quick-xml",
"thiserror 2.0.12", "thiserror 2.0.12",

View File

@@ -2,7 +2,7 @@
members = ["crates/*"] members = ["crates/*"]
[workspace.package] [workspace.package]
version = "0.6.0" version = "0.6.4"
edition = "2024" edition = "2024"
description = "A CalDAV server" description = "A CalDAV server"
repository = "https://github.com/lennart-k/rustical" repository = "https://github.com/lennart-k/rustical"

View File

@@ -1,11 +1,13 @@
use crate::config::NextcloudLoginConfig; use crate::config::NextcloudLoginConfig;
use axum::Router; use axum::Router;
use axum::body::Body; use axum::body::{Body, HttpBody};
use axum::extract::Request; use axum::extract::Request;
use axum::middleware::Next;
use axum::response::{Redirect, Response}; use axum::response::{Redirect, Response};
use axum::routing::{any, options}; use axum::routing::{any, options};
use axum_extra::TypedHeader; use axum_extra::TypedHeader;
use headers::{HeaderMapExt, UserAgent}; use headers::{HeaderMapExt, UserAgent};
use http::header::CONNECTION;
use http::{HeaderValue, StatusCode}; use http::{HeaderValue, StatusCode};
use rustical_caldav::caldav_router; use rustical_caldav::caldav_router;
use rustical_carddav::carddav_router; use rustical_carddav::carddav_router;
@@ -60,7 +62,7 @@ pub fn make_app<AS: AddressbookStore, CS: CalendarStore, S: SubscriptionStore>(
.route( .route(
"/.well-known/caldav", "/.well-known/caldav",
any(async |TypedHeader(ua): TypedHeader<UserAgent>| { any(async |TypedHeader(ua): TypedHeader<UserAgent>| {
if ua.as_str().contains("remindd") { if ua.as_str().contains("remindd") || ua.as_str().contains("dataaccessd") {
// remindd is an Apple Calendar User Agent // remindd is an Apple Calendar User Agent
// Even when explicitly configuring a principal URL in Apple Calendar Apple // Even when explicitly configuring a principal URL in Apple Calendar Apple
// will not respect that configuration but call /.well-known/caldav, // will not respect that configuration but call /.well-known/caldav,
@@ -178,4 +180,21 @@ pub fn make_app<AS: AddressbookStore, CS: CalendarStore, S: SubscriptionStore>(
}, },
), ),
) )
.layer(axum::middleware::from_fn(
async |req: Request, next: Next| {
// Closes the connection if the request body might've not been fully consumed
// Otherwise subsequent requests reusing the connection might fail.
// See https://github.com/lennart-k/rustical/issues/77
let body_empty = req.body().is_end_stream();
let mut response = next.run(req).await;
if !body_empty
&& (response.status().is_server_error() || response.status().is_client_error())
{
response
.headers_mut()
.insert(CONNECTION, HeaderValue::from_static("close"));
}
response
},
))
} }