2323
2424#ifdef Arduino_h
2525// arduino is not compatible with std::vector
26+ // It is possible to restore these defines, but one can use _min and _max instead. Or std::min, std::max.
2627#undef min
2728#undef max
2829#endif
2930#include " DynamicBuffer.h"
30- // It is possible to restore these defines, but one can use _min and _max instead. Or std::min, std::max.
3131
3232class AsyncBasicResponse : public AsyncWebServerResponse {
3333 private:
@@ -42,10 +42,6 @@ class AsyncBasicResponse: public AsyncWebServerResponse {
4242class AsyncAbstractResponse : public AsyncWebServerResponse {
4343 private:
4444 String _head;
45- // Data is inserted into cache at begin().
46- // This is inefficient with vector, but if we use some other container,
47- // we won't be able to access it as contiguous array of bytes when reading from it,
48- // so by gaining performance in one place, we'll lose it in another.
4945 Walkable<DynamicBuffer> _packet, _cache;
5046 size_t _readDataFromCacheOrContent (uint8_t * data, const size_t len);
5147 size_t _fillBufferAndProcessTemplates (uint8_t * buf, size_t maxLen);
@@ -118,13 +114,13 @@ class AsyncProgmemResponse: public AsyncAbstractResponse {
118114 virtual size_t _fillBuffer (uint8_t *buf, size_t maxLen) override ;
119115};
120116
121- class cbuf ;
122-
123117class AsyncResponseStream : public AsyncAbstractResponse , public Print {
124118 private:
125- cbuf *_content;
119+ DynamicBufferList _content;
120+ DynamicBufferListPrint _print;
121+ size_t _offset;
126122 public:
127- AsyncResponseStream (const String& contentType, size_t bufferSize);
123+ AsyncResponseStream (const String& contentType, size_t bufferSize=TCP_MSS );
128124 ~AsyncResponseStream ();
129125 bool _sourceValid () const { return (_state < RESPONSE_END); }
130126 virtual size_t _fillBuffer (uint8_t *buf, size_t maxLen) override ;
0 commit comments