4#include "../Async/Async.h"
5#include "../AsyncStreams/AsyncRequestStreams.h"
6#include "HttpConnection.h"
7#include "HttpMultipartParser.h"
45 bool isContentDisposition =
false;
53 size_t remainingBytes = 0;
60 template <
int RequestsSize>
63 static_assert(RequestsSize >= 2,
"HttpAsyncFileServer::StreamQueue requires RequestsSize >= 2");
67 readableFileStream.setReadQueue(readQueue);
68 writableFileStream.setWriteQueue(writeQueue);
91 bool useAsyncFileSend =
true;
Definition AsyncStreams.h:52
Asynchronous I/O (files, sockets, timers, processes, fs events, threads wake-up) (see Async) AsyncEve...
Definition Async.h:1386
Sends file contents to a socket using zero-copy when available (sendfile, TransmitFile).
Definition Async.h:974
Definition AsyncStreams.h:219
An AsyncSequence using a SC::ThreadPool to execute one or more SC::AsyncRequest in a background threa...
Definition Async.h:1116
Definition AsyncStreams.h:348
[UniqueHandleDeclaration2Snippet]
Definition File.h:122
Definition HttpAsyncFileServer.h:62
Definition HttpAsyncFileServer.h:36
Definition HttpAsyncFileServer.h:51
Support class for HttpAsyncFileServer holding file stream and pipeline.
Definition HttpAsyncFileServer.h:26
Http file server statically serves files from a directory.
Definition HttpAsyncFileServer.h:21
void setUseAsyncFileSend(bool value)
Controls whether to use AsyncFileSend optimization for GET requests (default: true)
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.
Result handleRequest(HttpAsyncFileServer::Stream &stream, HttpConnection &connection)
Handles the request, serving the requested file (GET) or creating a new one (PUT/POST) Call this meth...
bool getUseAsyncFileSend() const
Gets whether AsyncFileSend optimization is used for GET requests.
Definition HttpAsyncFileServer.h:84
Http connection abstraction holding both the incoming and outgoing messages in an HTTP transaction.
Definition HttpConnection.h:302
Incremental HTTP multipart/form-data parser.
Definition HttpMultipartParser.h:15
An ascii string used as boolean result. SC_TRY macro forwards errors to caller.
Definition Result.h:13
Pre-sized char array holding enough space to represent a file system path.
Definition StringPath.h:42
An read-only view over a string (to avoid including Strings library when parsing is not needed).
Definition StringSpan.h:37
Simple thread pool that executes tasks in a fixed number of worker threads.
Definition ThreadPool.h:38