Merge branch 'feat/rich-media-head' into 'develop'

RichMedia: Do a HEAD request to check content type/length

See merge request pleroma/pleroma!2995
This commit is contained in:
rinpatch 2020-09-14 12:38:00 +00:00
commit dee4639dbb
4 changed files with 99 additions and 1 deletions

View file

@ -1436,4 +1436,21 @@ defmodule HttpRequestMock do
inspect(headers)
}"}
end
# Most of the rich media mocks are missing HEAD requests, so we just return 404.
@rich_media_mocks [
"https://example.com/ogp",
"https://example.com/ogp-missing-data",
"https://example.com/twitter-card"
]
def head(url, _query, _body, _headers) when url in @rich_media_mocks do
{:ok, %Tesla.Env{status: 404, body: ""}}
end
def head(url, query, body, headers) do
{:error,
"Mock response not implemented for HEAD #{inspect(url)}, #{query}, #{inspect(body)}, #{
inspect(headers)
}"}
end
end