Http file server statically serves files from a directory. More...
#include <HttpAsyncFileServer.h>
Classes | |
| struct | Stream |
| Support class for HttpAsyncFileServer holding file stream and pipeline. More... | |
| struct | StreamQueue |
Public Member Functions | |
| Result | init (ThreadPool &threadPool, AsyncEventLoop &loop, StringSpan directoryToServe) |
| Initialize the web server on the given file system directory to serve. | |
| Result | close () |
| Removes any reference to the arguments passed during init. | |
| void | setUseAsyncFileSend (bool value) |
| Controls whether to use AsyncFileSend optimization for GET requests (default: true) | |
| bool | getUseAsyncFileSend () const |
| Gets whether AsyncFileSend optimization is used for GET requests. | |
| Result | handleRequest (HttpAsyncFileServer::Stream &stream, HttpConnection &connection) |
| Handles the request, serving the requested file (GET) or creating a new one (PUT/POST) Call this method in response to HttpConnectionsPool::onRequest. | |
Http file server statically serves files from a directory.
This class registers the onRequest callback provided by HttpAsyncServer to serves files from a given directory.
Example using compile time set buffers for connections:
Example using dynamically allocated buffers for connections:
| Result SC::HttpAsyncFileServer::close | ( | ) |
Removes any reference to the arguments passed during init.
|
inlinenodiscard |
Gets whether AsyncFileSend optimization is used for GET requests.
| Result SC::HttpAsyncFileServer::handleRequest | ( | HttpAsyncFileServer::Stream & | stream, |
| HttpConnection & | connection ) |
Handles the request, serving the requested file (GET) or creating a new one (PUT/POST) Call this method in response to HttpConnectionsPool::onRequest.
| Result SC::HttpAsyncFileServer::init | ( | ThreadPool & | threadPool, |
| AsyncEventLoop & | loop, | ||
| StringSpan | directoryToServe ) |
Initialize the web server on the given file system directory to serve.
| void SC::HttpAsyncFileServer::setUseAsyncFileSend | ( | bool | value | ) |
Controls whether to use AsyncFileSend optimization for GET requests (default: true)