fix(http): drop the partial body from truncated-read errors
Hackney 4.9 returns {:error, {:closed, partial}}. RelMe caches errors,
so it would keep up to max_body bytes per URL.
This commit is contained in:
parent
eabdde8a20
commit
48ec8518a3
2 changed files with 16 additions and 0 deletions
|
|
@ -79,8 +79,14 @@ defmodule Pleroma.HTTP do
|
|||
adapter,
|
||||
adapter_opts
|
||||
)
|
||||
|> drop_partial_body()
|
||||
end
|
||||
|
||||
# Hackney 4.9 returns the bytes read before the peer closed. No caller wants
|
||||
# them, and callers that cache errors would keep them.
|
||||
defp drop_partial_body({:error, {:closed, body}}) when is_binary(body), do: {:error, :closed}
|
||||
defp drop_partial_body(result), do: result
|
||||
|
||||
@spec request(Client.t(), keyword()) :: {:ok, Env.t()} | {:error, any()}
|
||||
def request(client, request), do: Tesla.request(client, request)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue