|
Webserv
|
An abstract interface for all HTTP response body sources. More...
#include <ResponseBody.hpp>
Public Member Functions | |
| IResponseBody () | |
| virtual | ~IResponseBody () |
| virtual ssize_t | read (char *buffer, size_t size)=0 |
| Reads a chunk of the body into the provided buffer. This is a non-blocking operation. | |
| virtual size_t | size () const =0 |
| Returns the total size of the body in bytes, if known. | |
| virtual bool | isDone () const =0 |
| Checks if the body source has been fully read. | |
| virtual int | getEventSourceFd () const |
| Retrieves the file descriptor for event-driven body sources. | |
| virtual bool | hasHeaderParsing () const |
| Indicates if the data read from this source contains HTTP headers that need to be parsed by the server (e.g., CGI output). | |
Private Member Functions | |
| IResponseBody (IResponseBody const &) | |
| IResponseBody const & | operator= (IResponseBody const &) |
An abstract interface for all HTTP response body sources.
This class defines a "strategy" for sending a response body. It allows the Reactor to stream data from any source (memory, file, CGI pipe) by simply calling read(), without needing to know the underlying type.
|
inline |
|
inlinevirtual |
|
private |
|
virtual |
Retrieves the file descriptor for event-driven body sources.
This method is used by the Reactor to determine if the response body source requires monitoring via the event loop (epoll).
Reimplemented in http::BodyFromCgi.
|
virtual |
Indicates if the data read from this source contains HTTP headers that need to be parsed by the server (e.g., CGI output).
Reimplemented in http::BodyFromCgi.
|
pure virtual |
Checks if the body source has been fully read.
Implemented in http::BodyFromCgi, http::BodyInMemory, and http::FileBody.
|
private |
|
pure virtual |
Reads a chunk of the body into the provided buffer. This is a non-blocking operation.
| buffer | An output buffer to write data into. |
| size | The maximum size of the buffer. |
Implemented in http::BodyFromCgi, http::BodyInMemory, and http::FileBody.
|
pure virtual |
Returns the total size of the body in bytes, if known.
Implemented in http::BodyFromCgi, http::BodyInMemory, and http::FileBody.