Skip to content

Commit 7bf8437

Browse files
committed
More tweaks from additional Copilot review
1 parent 4b24f82 commit 7bf8437

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

examples/ChunkRequest/ChunkRequest.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using namespace asyncsrv;
2424

2525
// Tests:
2626
//
27-
// Upload a file with PUT
27+
// Upload a file with PUT
2828
// curl -T myfile.txt http://192.168.4.1/
2929
//
3030
// Upload a file with PUT using chunked encoding
@@ -78,7 +78,7 @@ void handleRequest(AsyncWebServerRequest *request) {
7878
state->outFile.close();
7979
request->send(201); // Created
8080
}
81-
// Finally, releast the resources used by state
81+
// Finally, release the resources used by state
8282
delete state;
8383
request->_tempObject = nullptr;
8484
return;
@@ -105,7 +105,7 @@ void handleRequest(AsyncWebServerRequest *request) {
105105
request->send(403);
106106
}
107107

108-
void handleBody(AsyncWebServerRequest *request, unsigned char *data, size_t len, size_t index, size_t total) {
108+
void handleBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) {
109109
if (request->method() == HTTP_PUT) {
110110
auto state = static_cast<RequestState *>(request->_tempObject);
111111
if (index == 0) {
@@ -125,7 +125,7 @@ void handleBody(AsyncWebServerRequest *request, unsigned char *data, size_t len,
125125
#endif
126126
avail -= 4096; // Reserve a block for overhead
127127
if (total > avail) {
128-
Serial.printf("PUT %d bytes will not fit in available space (%d).\n", total, avail);
128+
Serial.printf("PUT %u bytes will not fit in available space (%u).\n", total, avail);
129129
request->send(507, "text/plain", "Too large for available storage\r\n");
130130
return;
131131
}

src/WebRequest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ bool AsyncWebServerRequest::_parseChunkedBytes(uint8_t *buf, size_t len) {
445445
// (e.g. an open file), so it is probably best to just ignore
446446
// the rest of the data and give handleRequest a chance to
447447
// clean up.
448+
_chunkSize = 0;
449+
return true;
448450
}
449451
}
450452
}
@@ -513,8 +515,6 @@ bool AsyncWebServerRequest::_parseReqHeader() {
513515
_chunkSize = 0;
514516
_chunkStartIndex = 0;
515517
_chunkedParseState = CHUNK_LENGTH;
516-
_itemIsFile = true;
517-
_itemFilename = _url;
518518
}
519519
}
520520
_headers.emplace_back(std::move(header));

0 commit comments

Comments
 (0)