diff --git a/src/ESPAsyncWebServer.h b/src/ESPAsyncWebServer.h index 7ae38b4..7da11f9 100644 --- a/src/ESPAsyncWebServer.h +++ b/src/ESPAsyncWebServer.h @@ -195,6 +195,8 @@ class AsyncWebServerRequest { void setHandler(AsyncWebHandler *handler){ _handler = handler; } void addInterestingHeader(String name); + void redirect(String url); + void send(AsyncWebServerResponse *response); void send(int code, String contentType=String(), String content=String()); void send(FS &fs, String path, String contentType=String(), bool download=false); diff --git a/src/WebRequest.cpp b/src/WebRequest.cpp index b4149aa..a02aa7f 100644 --- a/src/WebRequest.cpp +++ b/src/WebRequest.cpp @@ -694,6 +694,12 @@ void AsyncWebServerRequest::sendChunked(String contentType, AwsResponseFiller ca send(beginChunkedResponse(contentType, callback)); } +void AsyncWebServerRequest::redirect(String url){ + AsyncWebServerResponse * response = beginResponse(302); + response->addHeader("Location",url); + send(response); +} + bool AsyncWebServerRequest::authenticate(const char * username, const char * password){ if(_authorization.length()){