req
req copied to clipboard
response body is compressed in the retry function I provided
I am doing this
Req.request(base_request(), url: "some url", method: :get)
defp base_request do
Req.new(retry: &maybe_retry/2, retry_delay: &retry_delay/1, max_retries: 10)
end
and inside my maybe_retry/2
function, when I try to access the response.body
, the content is compressed.
After I do this below, it works.
defp maybe_retry(request, %Req.Response{status: 403} = response) do
{_request, %Req.Response{body: decompressed_body}} = Req.Steps.decompress_body({request, response})
decoded_body = Jason.decode!(decompressed_body)
match?(%{"message" => "You have exceeded a secondary rate limit" <> _}, decoded_body)
end
I assumed that the body will be already decompressed as it is in the result of the Req.new()
call. Am I mistaken or is this a bug?