- defp body_size_constraint(size, limit) when is_integer(limit) and limit > 0 and size >= limit do
- {:error, :body_too_large}
- end
-
- defp body_size_constraint(_, _), do: :ok
-
- defp check_read_duration(nil = _duration, max), do: check_read_duration(@max_read_duration, max)
-
- defp check_read_duration(duration, max)
- when is_integer(duration) and is_integer(max) and max > 0 do
- if duration > max do
- {:error, :read_duration_exceeded}
- else
- {:ok, {duration, :erlang.system_time(:millisecond)}}
- end
- end
-
- defp check_read_duration(_, _), do: {:ok, :no_duration_limit, :no_duration_limit}
-
- defp increase_read_duration({previous_duration, started})
- when is_integer(previous_duration) and is_integer(started) do
- duration = :erlang.system_time(:millisecond) - started
- {:ok, previous_duration + duration}
- end
-
- defp increase_read_duration(_) do
- {:ok, :no_duration_limit, :no_duration_limit}
- end
-
- defp client, do: Pleroma.ReverseProxy.Client.Wrapper
-