carddav, caldav: add missing headers on PUT

ETag and Last-Modified should be set to the new calendar object or
address object properties.
This commit is contained in:
Thomas Müller
2024-02-20 15:54:28 +01:00
committed by Simon Ser
parent 25f1014ef2
commit 3ed9a4f052
6 changed files with 64 additions and 42 deletions

View File

@@ -38,7 +38,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
b := backend{h.FileSystem}
hh := internal.Handler{&b}
hh := internal.Handler{Backend: &b}
hh.ServeHTTP(w, r)
}
@@ -193,18 +193,25 @@ func (b *backend) PropPatch(r *http.Request, update *internal.PropertyUpdate) (*
return nil, internal.HTTPErrorf(http.StatusForbidden, "webdav: PROPPATCH is unsupported")
}
func (b *backend) Put(r *http.Request) (*internal.Href, error) {
func (b *backend) Put(w http.ResponseWriter, r *http.Request) error {
wc, err := b.FileSystem.Create(r.Context(), r.URL.Path)
if err != nil {
return nil, err
return err
}
defer wc.Close()
if _, err := io.Copy(wc, r.Body); err != nil {
return nil, err
return err
}
if err := wc.Close(); err != nil {
return err
}
return nil, wc.Close()
w.WriteHeader(http.StatusCreated)
// TODO: Last-Modified, ETag, Content-Type if the request has been copied
// verbatim
// TODO: http.StatusNoContent if the resource already existed
return nil
}
func (b *backend) Delete(r *http.Request) error {