4#if !defined(USE_ESP32) && defined(USE_ARDUINO)
6#include <ESPAsyncWebServer.h>
49 void begin(AsyncWebServerRequest *request,
const char *status,
const char *content_type,
50 std::span<const HttpHeader> headers,
const char *body =
nullptr);
73 int log_id()
const {
return static_cast<int>(
reinterpret_cast<uintptr_t
>(
this) & 0xFFFF); }
85 friend class StreamHandoffResponse;
bool safe_to_delete() const
The connection is gone; no network callback still references this object.
RAMUniquePtr< char[]> head_rest_
void loop()
Main loop, every pass. Aborts (RST) a stream whose last send went unacknowledged for SEND_STALL_TIMEO...
void close()
Main loop. Closes the connection; safe to call more than once.
AsyncStreamResponse(const AsyncStreamResponse &)=delete
void __attribute__((cold)) close_stuck_(uint32_t elapsed_ms
size_t space_after_write_
void begin(AsyncWebServerRequest *request, const char *status, const char *content_type, std::span< const HttpHeader > headers, const char *body=nullptr)
Network context, from a request handler, once.
ssize_t write(StreamIovec *iov, int iovcnt)
Main loop.
bool stall_or_close_(const LogString *reason)
void attach_(AsyncClient *client, RAMUniquePtr< char[]> head_rest, bool head_kept)
AsyncStreamResponse & operator=(const AsyncStreamResponse &)=delete
std::atomic< StreamState > state_
static constexpr uint32_t SEND_STALL_TIMEOUT_MS
void const LogString * reason
bool is_connected() const
The client is still connected.
AsyncStreamResponse()=default
int log_id() const
An id for log lines only.
static constexpr uint32_t STALL_RETRY_MS
bool is_attached() const
The connection is taken from the request and the head queued; write() needs it.
std::atomic< bool > ack_timed_out_
~AsyncStreamResponse()
Main loop, once safe_to_delete(): frees the connection.
void close_client_(bool abort=false)
How long sends have made no progress.
StreamState
A long lived response the main loop writes to without blocking, on ESPAsyncWebServer; the same interf...
@ STREAM_STATE_DISCONNECTED
std::unique_ptr< T, RAMDeleter< T > > RAMUniquePtr
unique_ptr over RAMAllocator storage
One entry of the gather list AsyncStreamResponse::write() takes; the TCP libraries take plain buffers...