From ba1153ae0974a411c0bae92a79a2fdac94a19225 Mon Sep 17 00:00:00 2001 From: Mathieu Carbou Date: Tue, 8 Apr 2025 00:32:06 +0200 Subject: [PATCH] Expose AsyncResponseStream::available() to get the number of bytes to be read in the temporary buffer, and to be sent on the wire for the response --- src/WebResponseImpl.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/WebResponseImpl.h b/src/WebResponseImpl.h index 80dbca8fc..4a97492a2 100644 --- a/src/WebResponseImpl.h +++ b/src/WebResponseImpl.h @@ -168,6 +168,12 @@ class AsyncResponseStream : public AsyncAbstractResponse, public Print { size_t _fillBuffer(uint8_t *buf, size_t maxLen) override final; size_t write(const uint8_t *data, size_t len); size_t write(uint8_t data); + /** + * @brief Returns the number of bytes available in the stream. + */ + size_t available() const { + return _content.length(); // note: _content.available() is not const + } using Print::write; };