Check multiple Accept headers for content-type (#1935)

This commit is contained in:
tobi 2022-05-27 19:19:14 +02:00 committed by GitHub
parent e9405d1065
commit 2307321c79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {