Struct BinaryResponse

Struct Documentation

struct BinaryResponse

Response shape returned by RouteRegistry::binary_download handlers. The framework wires the provider callback into cpp-httplib’s range-aware content provider machinery. Range support is opt-in via supports_ranges because not every backend can serve byte ranges efficiently.

Minimum viable shape - real-world callers (bulkdata, snapshot download) will tune the contract in their migration commit.

Public Members

std::function<bool(uint64_t offset, uint64_t length, httplib::DataSink &sink)> provider

Range-aware content provider. offset and length are byte offsets into the logical resource; the callback writes the requested slice into sink and returns true to continue or false to abort the stream.

std::string content_type

MIME type (e.g. application/octet-stream, application/gzip).

std::optional<std::string> filename

Optional download filename; rendered as Content-Disposition if set.

bool supports_ranges = {false}

True iff the provider honours offset/length. False -> framework serves the full body in one shot.

uint64_t total_size = {0}

Total size in bytes; cpp-httplib uses this for Content-Length.