Skip to content

Commit c8da12b

Browse files
Fix sync. HEAD responses with content-length
1 parent 1933c71 commit c8da12b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/HttpResponse.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Authored by Alex Hultman, 2018-2020.
2+
* Authored by Alex Hultman, 2018-2025.
33
* Intellectual property of third-party.
44
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -196,8 +196,11 @@ struct HttpResponse : public AsyncSocket<SSL> {
196196
Super::timeout(HTTP_TIMEOUT_S);
197197
}
198198

199-
/* Remove onAborted function if we reach the end */
200-
if (httpResponseData->offset == totalSize) {
199+
/* Remove onAborted, onWritable function and mark done if we reach the end, or if we were given no data (faked size like in HEAD response) */
200+
/* I need to figure out if this line should rather be simply httpResponseData->offset == data.length() */
201+
/* No that can't be right, tryEnd with fake length should not complete the response even if the smaller chunk wrote in one go */
202+
/* Possibly need to separate endWithoutBody and tryEnd with fake length into two separate calls with a boolean that explicitly marks isHeadOnly */
203+
if (httpResponseData->offset == totalSize || !data.length()) {
201204
httpResponseData->markDone();
202205

203206
/* We need to check if we should close this socket here now */

0 commit comments

Comments
 (0)