修复 KNMI S3 下载被 Auth header 污染导致 netCDF 解析失败
This commit is contained in:
@@ -32,13 +32,13 @@ class KnmiSourceMixin:
|
|||||||
import os
|
import os
|
||||||
return str(os.getenv("KNMI_API_KEY") or "").strip()
|
return str(os.getenv("KNMI_API_KEY") or "").strip()
|
||||||
|
|
||||||
def _knmi_http_get(self, url: str, api_key: str) -> bytes:
|
def _knmi_http_get(self, url: str, api_key: str = "") -> bytes:
|
||||||
headers = {"Authorization": api_key}
|
"""Download file. Does NOT send auth header — download URLs are pre-signed S3 links."""
|
||||||
getter = getattr(self, "_http_get", None)
|
getter = getattr(self, "_http_get", None)
|
||||||
if callable(getter):
|
if callable(getter):
|
||||||
resp = getter(url, headers=headers)
|
resp = getter(url)
|
||||||
return resp.content if hasattr(resp, "content") else resp
|
return resp.content if hasattr(resp, "content") else resp
|
||||||
resp = self.session.get(url, timeout=self.timeout, headers=headers)
|
resp = self.session.get(url, timeout=self.timeout)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
return resp.content
|
return resp.content
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user