Skip to content

Commit fef157b

Browse files
authored
Merge pull request #1766 from pbiering/fix-1765-put-update
Fix 1765 put update
2 parents 600c82d + f6199d7 commit fef157b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Adjust: [auth] ldap: use ldap_user_attr either first element of list or directly
55
* Fix: use value of property for time range filter
66
* Add: [auth] ldap: option ldap_security (none, startls, tls) for additional support of STARTTLS, deprecate ldap_use_ssl
7+
* Fix: return 204 instead of 201 in case PUT updates an item
78

89
## 3.5.1
910

radicale/app/put.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@ def do_PUT(self, environ: types.WSGIEnviron, base_prefix: str,
282282
logger.warning(
283283
"Bad PUT request on %r (upload): %s", path, e, exc_info=True)
284284
return httputils.BAD_REQUEST
285+
if (item and item.uid == prepared_item.uid):
286+
logger.debug("PUT request updated existing item %r", path)
287+
headers = {"ETag": etag}
288+
return client.NO_CONTENT, headers, None
285289

286290
headers = {"ETag": etag}
287291
return client.CREATED, headers, None

radicale/tests/test_base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This file is part of Radicale - CalDAV and CardDAV server
22
# Copyright © 2012-2017 Guillaume Ayoub
33
# Copyright © 2017-2022 Unrud <unrud@outlook.com>
4-
# Copyright © 2024-2024 Peter Bieringer <pb@bieringer.de>
4+
# Copyright © 2024-2025 Peter Bieringer <pb@bieringer.de>
55
#
66
# This library is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -222,7 +222,7 @@ def test_update_event(self) -> None:
222222
event_modified = get_file_content("event1_modified.ics")
223223
path = "/calendar.ics/event1.ics"
224224
self.put(path, event)
225-
self.put(path, event_modified)
225+
self.put(path, event_modified, check=204)
226226
_, answer = self.get("/calendar.ics/")
227227
assert answer.count("BEGIN:VEVENT") == 1
228228
_, answer = self.get(path)
@@ -1594,8 +1594,8 @@ def test_report_sync_collection_modify_undo(self) -> None:
15941594
self.put(event_path, event1)
15951595
sync_token, responses = self._report_sync_token(calendar_path)
15961596
assert len(responses) == 1 and responses[event_path] == 200
1597-
self.put(event_path, event2)
1598-
self.put(event_path, event1)
1597+
self.put(event_path, event2, check=204)
1598+
self.put(event_path, event1, check=204)
15991599
sync_token, responses = self._report_sync_token(
16001600
calendar_path, sync_token)
16011601
if not self.full_sync_token_support and not sync_token:

0 commit comments

Comments
 (0)