From 546050505ba27aeea0353680442de000b4438cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 5 Sep 2024 10:28:30 +0200 Subject: [PATCH] write body after header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/ocm-generate-invite-event.md | 1 + internal/http/services/sciencemesh/token.go | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/changelog/unreleased/ocm-generate-invite-event.md b/changelog/unreleased/ocm-generate-invite-event.md index 973e9728e1..811edd7f7b 100644 --- a/changelog/unreleased/ocm-generate-invite-event.md +++ b/changelog/unreleased/ocm-generate-invite-event.md @@ -3,5 +3,6 @@ Enhancement: Publish an event when an OCM invite is generated The ocm generate-invite endpoint now publishes an event whenever an invitation is requested and generated. This event can be subscribed to by other services to react to the generated invitation. +https://github.com/cs3org/reva/pull/4836 https://github.com/cs3org/reva/pull/4832 https://github.com/owncloud/ocis/issues/9583 diff --git a/internal/http/services/sciencemesh/token.go b/internal/http/services/sciencemesh/token.go index ff8d33002f..9e42b3d3fb 100644 --- a/internal/http/services/sciencemesh/token.go +++ b/internal/http/services/sciencemesh/token.go @@ -100,10 +100,12 @@ func (h *tokenHandler) Generate(w http.ResponseWriter, r *http.Request) { return } + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) // FIXME this should be a 201 created status. Tracked in https://github.com/cs3org/reva/issues/4838 + tknRes := h.prepareGenerateTokenResponse(genTokenRes.GetInviteToken()) if err := json.NewEncoder(w).Encode(tknRes); err != nil { reqres.WriteError(w, r, reqres.APIErrorServerError, "error marshalling token data", err) - return } if h.eventStream != nil { @@ -122,8 +124,6 @@ func (h *tokenHandler) Generate(w http.ResponseWriter, r *http.Request) { } } - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) } // generateRequest is the request body for the Generate endpoint.