File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/*
2- * Authored by Alex Hultman, 2018-2025 .
2+ * Authored by Alex Hultman, 2018-2026 .
33 * Intellectual property of third-party.
44
55 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -427,6 +427,25 @@ struct HttpResponse : public AsyncSocket<SSL> {
427427 return this ;
428428 }
429429
430+ /* Begin writing the response body. Useful for chunked encodings whose first chunk is not yet known */
431+ void beginWrite () {
432+ /* Write status if not already done */
433+ writeStatus (HTTP_200_OK );
434+
435+ HttpResponseData<SSL > *httpResponseData = getHttpResponseData ();
436+
437+ if (!(httpResponseData->state & HttpResponseData<SSL >::HTTP_WRITE_CALLED )) {
438+ /* Write mark on first call to write */
439+ writeMark ();
440+
441+ writeHeader (" Transfer-Encoding" , " chunked" );
442+ httpResponseData->state |= HttpResponseData<SSL >::HTTP_WRITE_CALLED ;
443+
444+ /* Start of the body */
445+ Super::write (" \r\n " , 2 );
446+ }
447+ }
448+
430449 /* End without a body (no content-length) or end with a spoofed content-length. */
431450 void endWithoutBody (std::optional<size_t > reportedContentLength = std::nullopt , bool closeConnection = false ) {
432451 if (reportedContentLength.has_value ()) {
You can’t perform that action at this time.
0 commit comments