From 2307321c7996deb11c1c72f12fad53bd0b5fb4f5 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 27 May 2022 19:19:14 +0200 Subject: [PATCH] Check multiple Accept headers for content-type (#1935) --- router/middleware/activityPub.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/router/middleware/activityPub.go b/router/middleware/activityPub.go index 3c3805a0f..51fdc09ca 100644 --- a/router/middleware/activityPub.go +++ b/router/middleware/activityPub.go @@ -22,8 +22,10 @@ func RequireActivityPubOrRedirect(handler http.HandlerFunc) http.HandlerFunc { } acceptedContentTypes := []string{"application/json", "application/json+ld", "application/activity+json", `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`} - acceptString := r.Header.Get("Accept") - accept := strings.Split(acceptString, ",") + var accept []string + for _, a := range r.Header.Values("Accept") { + accept = append(accept, strings.Split(a, ",")...) + } for _, singleType := range accept { if _, accepted := utils.FindInSlice(acceptedContentTypes, strings.TrimSpace(singleType)); accepted {