1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-09-08 06:28:00 +03:00

WebServer: handle initial read/close timeouts asynchronously

If there is a delay before data becomes available on a new connection
then the handler function blocks for up to 1 second, and there's another
wait on connection close for up to 2 seconds.

This doesn't make the whole server process asynchronous (there is another
delay between headers/data) but it helps when there are other events
that need attention while handling web requests.
This commit is contained in:
Simon Arlott
2016-01-10 15:47:50 +00:00
parent c61587f8d4
commit d099404eb8
2 changed files with 57 additions and 19 deletions

View File

@@ -29,6 +29,7 @@
enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };
enum HTTPUploadStatus { UPLOAD_FILE_START, UPLOAD_FILE_WRITE, UPLOAD_FILE_END,
UPLOAD_FILE_ABORTED };
enum HTTPClientStatus { HC_NONE, HC_WAIT_READ, HC_WAIT_CLOSE };
#define HTTP_DOWNLOAD_UNIT_SIZE 1460
#define HTTP_UPLOAD_BUFLEN 2048
@@ -151,6 +152,8 @@ protected:
WiFiClient _currentClient;
HTTPMethod _currentMethod;
String _currentUri;
HTTPClientStatus _currentStatus;
unsigned long _statusChange;
RequestHandler* _currentHandler;
RequestHandler* _firstHandler;