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
|
|
@ -29,6 +29,10 @@ defmodule Pleroma.HTTPTest do
|
|||
%{method: :post, url: "http://example.com/world"} ->
|
||||
%Tesla.Env{status: 200, body: "world"}
|
||||
|
||||
# Hackney 4.9 hands back the bytes it read before the peer closed.
|
||||
%{method: :get, url: "http://example.com/truncated"} ->
|
||||
{:error, {:closed, "partial body"}}
|
||||
|
||||
%{method: :get, url: "https://example.com/emoji/Pack%201/koronebless.png?foo=bar+baz"} ->
|
||||
%Tesla.Env{status: 200, body: "emoji data"}
|
||||
|
||||
|
|
@ -81,6 +85,12 @@ defmodule Pleroma.HTTPTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "get/1 with a truncated body" do
|
||||
test "drops the partial body from the error" do
|
||||
assert HTTP.get("http://example.com/truncated") == {:error, :closed}
|
||||
end
|
||||
end
|
||||
|
||||
describe "get/2 (with headers)" do
|
||||
test "returns successfully result for json content-type" do
|
||||
assert HTTP.get("http://example.com/hello", [{"content-type", "application/json"}]) ==
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue