add chunked to simple sends

This commit is contained in:
Me No Dev
2016-01-27 19:55:32 +02:00
parent 31a699a46f
commit 3cdefde295
2 changed files with 9 additions and 4 deletions

View File

@@ -163,6 +163,7 @@ class AsyncWebServerRequest {
void send(FS &fs, String path, String contentType=String(), bool download=false); void send(FS &fs, String path, String contentType=String(), bool download=false);
void send(Stream &stream, String contentType, size_t len); void send(Stream &stream, String contentType, size_t len);
void send(String contentType, size_t len, AwsResponseFiller callback); void send(String contentType, size_t len, AwsResponseFiller callback);
void sendChunked(String contentType, AwsResponseFiller callback);
AsyncWebServerResponse *beginResponse(int code, String contentType=String(), String content=String()); AsyncWebServerResponse *beginResponse(int code, String contentType=String(), String content=String());
AsyncWebServerResponse *beginResponse(FS &fs, String path, String contentType=String(), bool download=false); AsyncWebServerResponse *beginResponse(FS &fs, String path, String contentType=String(), bool download=false);

View File

@@ -635,21 +635,25 @@ AsyncResponseStream * AsyncWebServerRequest::beginResponseStream(String contentT
} }
void AsyncWebServerRequest::send(int code, String contentType, String content){ void AsyncWebServerRequest::send(int code, String contentType, String content){
send(new AsyncBasicResponse(code, contentType, content)); send(beginResponse(code, contentType, content));
} }
void AsyncWebServerRequest::send(FS &fs, String path, String contentType, bool download){ void AsyncWebServerRequest::send(FS &fs, String path, String contentType, bool download){
if(fs.exists(path) || (!download && fs.exists(path+".gz"))){ if(fs.exists(path) || (!download && fs.exists(path+".gz"))){
send(new AsyncFileResponse(fs, path, contentType, download)); send(beginResponse(fs, path, contentType, download));
} else send(404); } else send(404);
} }
void AsyncWebServerRequest::send(Stream &stream, String contentType, size_t len){ void AsyncWebServerRequest::send(Stream &stream, String contentType, size_t len){
send(new AsyncStreamResponse(stream, contentType, len)); send(beginResponse(stream, contentType, len));
} }
void AsyncWebServerRequest::send(String contentType, size_t len, AwsResponseFiller callback){ void AsyncWebServerRequest::send(String contentType, size_t len, AwsResponseFiller callback){
send(new AsyncCallbackResponse(contentType, len, callback)); send(beginResponse(contentType, len, callback));
}
void AsyncWebServerRequest::sendChunked(String contentType, AwsResponseFiller callback){
send(beginChunkedResponse(contentType, callback));
} }