mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-06 09:59:31 -06:00
media handler updates
This commit is contained in:
parent
d797ddf704
commit
17a62d53ed
15 changed files with 237 additions and 55 deletions
|
|
@ -90,5 +90,14 @@ func (m *FileServer) ServeFile(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// TODO: do proper content negotiation here -- if the requester only accepts text/html we should try to serve them *something*
|
||||
// This is mostly needed because when sharing a link to a gts-hosted file on something like mastodon, the masto servers will
|
||||
// attempt to look up the content to provide a preview of the link, and they ask for text/html.
|
||||
if c.NegotiateFormat(content.ContentType) == "" {
|
||||
l.Debugf("couldn't negotiate content for Accept headers %+v: we have content type %s", c.Request.Header.Get("Accepted"), content.ContentType)
|
||||
c.AbortWithStatus(http.StatusNotAcceptable)
|
||||
return
|
||||
}
|
||||
|
||||
c.DataFromReader(http.StatusOK, content.ContentLength, content.ContentType, bytes.NewReader(content.Content), nil)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue