Skip to content

EntropyEngine::Networking::HTTP::StreamHandle

EntropyEngine::Networking::HTTP::StreamHandle

Section titled “EntropyEngine::Networking::HTTP::StreamHandle”

Handle to active streaming HTTP request. More…

#include <HttpClient.h>

Name
boolwaitForHeaders(std::chrono::milliseconds timeout =std::chrono::milliseconds(30000))
Waits for headers to be received.
size_tread(uint8_t * buffer, size_t size)
Reads up to size bytes from stream.
boolisDone() const
Checks if stream has completed.
intgetStatusCode() const
Gets HTTP status code (available after headers received).
HttpHeaderValuesMapgetHeadersMulti() const
Gets multi-valued response headers (available after headers received).
HttpHeadersgetHeaders() const
Gets response headers (available after headers received).
std::stringgetFailureReason() const
Gets failure reason if failed.
boolfailed() const
Checks if stream failed.
voidcancel()
Cancels the ongoing HTTP transfer.
StreamHandle(std::shared_ptr< StreamState > state)
Name
classHttpClient
class EntropyEngine::Networking::HTTP::StreamHandle;

Handle to active streaming HTTP request.

Provides incremental read access to response body. Use for large downloads where aggregated responses would exceed memory limits.

StreamOptions opts{.bufferBytes = 4 * 1024 * 1024};
auto handle = client.executeStream(req, opts);
std::vector<uint8_t> chunk(64 * 1024);
while (!handle.isDone()) {
size_t n = handle.read(chunk.data(), chunk.size());
processChunk(chunk.data(), n);
}
bool waitForHeaders(
std::chrono::milliseconds timeout =std::chrono::milliseconds(30000)
)

Waits for headers to be received.

Parameters:

  • timeout Maximum time to wait

Return: true if headers ready, false on timeout

size_t read(
uint8_t * buffer,
size_t size
)

Reads up to size bytes from stream.

Parameters:

  • buffer Destination buffer
  • size Maximum bytes to read

Return: Number of bytes actually read (0 if none available)

bool isDone() const

Checks if stream has completed.

Return: true if all data received and consumed

int getStatusCode() const

Gets HTTP status code (available after headers received).

Return: Status code, or 0 if headers not yet ready

HttpHeaderValuesMap getHeadersMulti() const

Gets multi-valued response headers (available after headers received).

Return: Map of header name to all values

HttpHeaders getHeaders() const

Gets response headers (available after headers received).

Return: Headers map (lowercase keys)

std::string getFailureReason() const

Gets failure reason if failed.

Return: Error message

bool failed() const

Checks if stream failed.

Return: true on error

void cancel()

Cancels the ongoing HTTP transfer.

Safe to call from any thread. Causes the transfer to abort promptly.

inline explicit StreamHandle(
std::shared_ptr< StreamState > state
)
friend class HttpClient(
HttpClient
);

Updated on 2026-01-26 at 17:14:35 -0500