Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/HttpResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,25 @@ struct HttpResponse : public AsyncSocket<SSL> {
return this;
}

/* Begin writing the response body. Useful for chunked encodings whose first chunk is not yet known */
void beginWrite() {
/* Write status if not already done */
writeStatus(HTTP_200_OK);

HttpResponseData<SSL> *httpResponseData = getHttpResponseData();

if (!(httpResponseData->state & HttpResponseData<SSL>::HTTP_WRITE_CALLED)) {
/* Write mark on first call to write */
writeMark();

writeHeader("Transfer-Encoding", "chunked");
httpResponseData->state |= HttpResponseData<SSL>::HTTP_WRITE_CALLED;

/* Start of the body */
Super::write("\r\n", 2);
}
}

/* End without a body (no content-length) or end with a spoofed content-length. */
void endWithoutBody(std::optional<size_t> reportedContentLength = std::nullopt, bool closeConnection = false) {
if (reportedContentLength.has_value()) {
Expand Down
32 changes: 0 additions & 32 deletions tests/Makefile

This file was deleted.