hydromodpy.core.io.http_client#

Unified HTTP client for HydroModPy data sources.

Single entry point used by every remote data provider (Hub’Eau, BRGM, IGN, Meteo-France / GeoSAS). Features:

  • persistent requests.Session

  • exponential backoff with jitter

  • honors Retry-After header (seconds or HTTP-date)

  • configurable default timeout

  • simple per-host token bucket to cap concurrent requests

  • stream() yields chunks while computing a SHA-256 digest

  • get_json() optionally validates the payload against a Pydantic model

  • pre/post request hooks for instrumentation

The client raises hydromodpy.core.exceptions.NetworkError when the server returns a non-recoverable status after all retry attempts, and hydromodpy.core.exceptions.DataSourceError for payload validation failures.

Functions

get_default_client()

Module-level singleton used by data providers that do not own a client.

Classes

HTTPClient(*[, timeout, max_retries, ...])

Unified HTTP client with backoff + streaming SHA-256.

StreamResult(sha256, size, status_code, url)

Result of HTTPClient.stream(): final path + digest metadata.