Skip to content

Commit 17da372

Browse files
committed
feat(http): Add ability to abort a request
1 parent c8026aa commit 17da372

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/ESPAsyncWebServer.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,15 @@ class AsyncWebServerRequest {
502502
return _paused;
503503
}
504504

505+
/**
506+
* @brief Aborts the request and close the client. Mark the request as sent.
507+
*/
508+
void abort();
509+
510+
bool isSent() const {
511+
return _sent;
512+
}
513+
505514
/**
506515
* @brief Get the Request parameter by name
507516
*

src/WebRequest.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,13 @@ AsyncWebServerRequestPtr AsyncWebServerRequest::pause() {
727727
return _this;
728728
}
729729

730+
void AsyncWebServerRequest::abort() {
731+
if (_sent) {
732+
_sent = true;
733+
_client->abort();
734+
}
735+
}
736+
730737
size_t AsyncWebServerRequest::headers() const {
731738
return _headers.size();
732739
}

0 commit comments

Comments
 (0)