mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 04:52:24 -05:00
[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 7050112af1). But things
seem to work reliably with a single accept header with multiple parts.
Fixes: #1793
This commit is contained in:
parent
2478d83c84
commit
e91cabb704
5 changed files with 127 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue