summaryrefslogtreecommitdiff
path: root/internal/transport
diff options
context:
space:
mode:
authorLibravatar Daenney <daenney@users.noreply.github.com>2023-05-16 15:08:45 +0200
committerLibravatar GitHub <noreply@github.com>2023-05-16 15:08:45 +0200
commite91cabb704b1cfc1cae438f5be8600e83dc5578e (patch)
treead0fd473a7327fc602c63acfaf57b68c0efc2ef6 /internal/transport
parent[bugfix] Fix proxy_pass in named location (#1794) (diff)
downloadgotosocial-e91cabb704b1cfc1cae438f5be8600e83dc5578e.tar.xz
[bugfix] Fix NegotiateFormat with multiple accept headers (#1797)
* [bugfix] Fix NegotiateAccept with multi accept There's a bug in Gin's NegotiateFormat that doesn't handle the presence of multilpe accept headers. This lifts the code from the PR @tsmethurst sent a year ago to Gin into our codebase to fix the issue. * [bugfix] Concat accept header in webfinger Some implementations bug out when there's multiple accept headers, including Gin (see 7050112af1ccc935ec542cb41fa8b07f7357539d). But things seem to work reliably with a single accept header with multiple parts. Fixes: #1793
Diffstat (limited to 'internal/transport')
-rw-r--r--internal/transport/finger.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/internal/transport/finger.go b/internal/transport/finger.go
index f106019b5..18b028a64 100644
--- a/internal/transport/finger.go
+++ b/internal/transport/finger.go
@@ -61,8 +61,11 @@ func prepWebfingerReq(ctx context.Context, loc, domain, username string) (*http.
// Prefer application/jrd+json, fall back to application/json.
// See https://www.rfc-editor.org/rfc/rfc7033#section-10.2.
- req.Header.Add("Accept", string(apiutil.AppJRDJSON))
- req.Header.Add("Accept", string(apiutil.AppJSON))
+ //
+ // Some implementations don't handle multiple accept headers properly,
+ // including Gin itself. So concat the accept header with a comma
+ // instead which seems to work reliably
+ req.Header.Add("Accept", string(apiutil.AppJRDJSON)+","+string(apiutil.AppJSON))
req.Header.Set("Host", req.URL.Host)
return req, nil