HTTP¶
Retry-aware HTTP helpers used internally by the GitHub backends. Wrap transport-layer exceptions into the SDK's typed error hierarchy.
fetch_json¶
ocx_mirror_sdk.http.fetch_json
¶
fetch_json(url: str, *, headers: dict[str, str] | None = None, params: dict[str, Any] | None = None, client: Client | None = None) -> Any
Fetch a URL and parse the response as JSON.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
Target URL.
TYPE:
|
headers
|
Optional request headers (e.g.
TYPE:
|
params
|
Optional query-string parameters (e.g.
TYPE:
|
client
|
Optional injected client. Defaults to the module-level
singleton (lazy-initialized with sane retry / timeout). Tests
should pass
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
HttpStatusError
|
Response status was 4xx/5xx. |
HttpTimeoutError
|
Request timed out. |
ApiResponseError
|
Body was not valid JSON. |
Source code in src/ocx_mirror_sdk/http.py
fetch_text¶
ocx_mirror_sdk.http.fetch_text
¶
Fetch a URL and return the response body as text.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
Target URL.
TYPE:
|
client
|
Optional injected client. See :func:
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
HttpStatusError
|
Response status was 4xx/5xx. |
HttpTimeoutError
|
Request timed out. |
Source code in src/ocx_mirror_sdk/http.py
post_json¶
ocx_mirror_sdk.http.post_json
¶
post_json(url: str, *, body: Any, headers: dict[str, str] | None = None, client: Client | None = None) -> Any
POST a JSON payload and parse the response as JSON.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
Target URL.
TYPE:
|
body
|
JSON-serializable request body.
TYPE:
|
headers
|
Optional request headers (e.g.
TYPE:
|
client
|
Optional injected client. See :func:
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
HttpStatusError
|
Response status was 4xx/5xx. |
HttpTimeoutError
|
Request timed out. |
ApiResponseError
|
Body was not valid JSON. |