summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/pleroma/http/adapter_helper.ex2
-rw-r--r--lib/pleroma/web/rich_media/helpers.ex16
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/pleroma/http/adapter_helper.ex b/lib/pleroma/http/adapter_helper.ex
index f8bde2ac3..4dbcccdcc 100644
--- a/lib/pleroma/http/adapter_helper.ex
+++ b/lib/pleroma/http/adapter_helper.ex
@@ -119,7 +119,7 @@ defmodule Pleroma.HTTP.AdapterHelper do
end
end
- #TODO add Finch support once we have an AdapterHelper for it
+ # TODO add Finch support once we have an AdapterHelper for it
@spec can_stream? :: bool()
def can_stream? do
case Application.get_env(:tesla, :adapter) do
diff --git a/lib/pleroma/web/rich_media/helpers.ex b/lib/pleroma/web/rich_media/helpers.ex
index 88bfbae68..db1310b23 100644
--- a/lib/pleroma/web/rich_media/helpers.ex
+++ b/lib/pleroma/web/rich_media/helpers.ex
@@ -11,10 +11,10 @@ defmodule Pleroma.Web.RichMedia.Helpers do
@spec rich_media_get(String.t()) :: {:ok, String.t()} | get_errors()
def rich_media_get(url) do
- case Pleroma.HTTP.AdapterHelper.can_stream?() do
- true -> stream(url)
- false -> head_first(url)
- end
+ case Pleroma.HTTP.AdapterHelper.can_stream?() do
+ true -> stream(url)
+ false -> head_first(url)
+ end
|> handle_result(url)
end
@@ -22,8 +22,8 @@ defmodule Pleroma.Web.RichMedia.Helpers do
with {_, {:ok, %Tesla.Env{status: 200, body: stream_body, headers: headers}}} <-
{:head, Pleroma.HTTP.get(url, req_headers(), http_options())},
{_, :ok} <- {:content_type, check_content_type(headers)},
- {_, :ok} <- {:content_length, check_content_length(headers)} do
- body = Enum.into(stream_body, <<>>)
+ {_, :ok} <- {:content_length, check_content_length(headers)},
+ body <- Enum.into(stream_body, <<>>) do
{:ok, body}
end
end
@@ -59,6 +59,10 @@ defmodule Pleroma.Web.RichMedia.Helpers do
{:get, _} ->
Logger.debug("Rich media error for #{url}: HTTP GET failed")
{:error, :get}
+
+ {:error, :recv_chunk_timeout} ->
+ Logger.debug("Rich media error for #{url}: HTTP streaming response failed")
+ {:error, :get}
end
end