Reject HRRR downloads when server ignores Range header
S3 returns 200 with the full ~116MB file instead of 206 for some older HRRR data. Treat this as a permanent failure instead of trying to parse the entire file.
This commit is contained in:
parent
5c5d398966
commit
8e1fd702f9
2 changed files with 6 additions and 1 deletions
|
|
@ -178,9 +178,13 @@ defmodule Microwaveprop.Weather.HrrrClient do
|
|||
Enum.map_join(ranges, ", ", fn {start, stop} -> "#{start}-#{stop}" end)
|
||||
|
||||
case Req.get(url, [{:headers, [{"Range", "bytes=#{range_header}"}]} | req_options()]) do
|
||||
{:ok, %{status: status, body: body}} when status in [200, 206] ->
|
||||
{:ok, %{status: 206, body: body}} ->
|
||||
{:ok, body}
|
||||
|
||||
{:ok, %{status: 200}} ->
|
||||
Logger.warning("HRRR server ignored Range header, returned full file")
|
||||
{:error, "HRRR range request not supported"}
|
||||
|
||||
{:ok, %{status: status}} ->
|
||||
{:error, "HRRR grib HTTP #{status}"}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ defmodule Microwaveprop.Workers.HrrrFetchWorker do
|
|||
|
||||
defp permanent_failure?("HRRR idx HTTP 404"), do: true
|
||||
defp permanent_failure?("HRRR grib HTTP 404"), do: true
|
||||
defp permanent_failure?("HRRR range request not supported"), do: true
|
||||
defp permanent_failure?(:outside_grid), do: true
|
||||
defp permanent_failure?("malformed section"), do: true
|
||||
defp permanent_failure?("missing sections: " <> _), do: true
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue