Skip to main content

Module http

Module http 

Source
Expand description

Thin reqwest wrapper around the studio API.

Every call goes through ApiClient::check, which:

  • emits a structured tracing event on success (debug) and failure (warn) so operators can see what the worker is talking to without having to enable wire-level logging in reqwest (complete also logs the upload byte size before the request so the attempted payload size is visible even when it never finishes), and
  • turns non-2xx responses into an anyhow error tagged with the operation name so the existing log shipper messages stay legible.

Structs§

ApiClient
HttpStatusError
Typed non-2xx response error so callers can branch on the status class (e.g. retry 5xx, never retry 4xx) without sniffing message strings. The rendered message keeps the legacy <op> failed: <status> — <body> shape existing tests and log consumers expect.

Functions§

is_transient_upload_error
True when the upload failed for a reason a short retry can fix: a 5xx from the studio or a transport-level error (connect refused, timeout, broken pipe). 4xx contract errors return false.
mime_for_ext
Map a binary output’s file extension to the MIME type sent as the multipart complete upload’s Content-Type. Single source of truth: every engine that emits a TaskResult binary extension (synthetic image → png/webp, sd-cpp → webp, tts → wav, synthetic video → webp, the video feature → gif) routes through here, so a new extension can’t silently drift into application/octet-stream and break the studio’s stored content-type.