3232
3333enum HTTPUploadStatus { UPLOAD_FILE_START, UPLOAD_FILE_WRITE, UPLOAD_FILE_END,
3434 UPLOAD_FILE_ABORTED };
35+ enum HTTPRawStatus { RAW_START, RAW_WRITE, RAW_END, RAW_ABORTED };
3536enum HTTPClientStatus { HC_NONE, HC_WAIT_READ, HC_WAIT_CLOSE };
3637enum HTTPAuthMethod { BASIC_AUTH, DIGEST_AUTH };
3738
@@ -41,6 +42,10 @@ enum HTTPAuthMethod { BASIC_AUTH, DIGEST_AUTH };
4142#define HTTP_UPLOAD_BUFLEN 1436
4243#endif
4344
45+ #ifndef HTTP_RAW_BUFLEN
46+ #define HTTP_RAW_BUFLEN 1436
47+ #endif
48+
4449#define HTTP_MAX_DATA_WAIT 5000 // ms to wait for the client to send the request
4550#define HTTP_MAX_POST_WAIT 5000 // ms to wait for POST data to arrive
4651#define HTTP_MAX_SEND_WAIT 5000 // ms to wait for data chunk to be ACKed
@@ -61,6 +66,15 @@ typedef struct {
6166 uint8_t buf[HTTP_UPLOAD_BUFLEN];
6267} HTTPUpload;
6368
69+ typedef struct
70+ {
71+ HTTPRawStatus status;
72+ size_t totalSize; // content size
73+ size_t currentSize; // size of data currently in buf
74+ uint8_t buf[HTTP_UPLOAD_BUFLEN];
75+ void *data; // additional data
76+ } HTTPRaw;
77+
6478#include " detail/RequestHandler.h"
6579
6680namespace fs {
@@ -97,6 +111,7 @@ class WebServer
97111 HTTPMethod method () { return _currentMethod; }
98112 virtual WiFiClient client () { return _currentClient; }
99113 HTTPUpload& upload () { return *_currentUpload; }
114+ HTTPRaw& raw () { return *_currentRaw; }
100115
101116 String pathArg (unsigned int i); // get request path argument by number
102117 String arg (String name); // get request argument value by name
@@ -196,6 +211,7 @@ class WebServer
196211 RequestArgument* _postArgs;
197212
198213 std::unique_ptr<HTTPUpload> _currentUpload;
214+ std::unique_ptr<HTTPRaw> _currentRaw;
199215
200216 int _headerKeysCount;
201217 RequestArgument* _currentHeaders;
0 commit comments