Don't write mark in the middle of streaming
This commit is contained in:
+11
-3
@@ -75,15 +75,17 @@ private:
|
|||||||
httpResponseData->state &= ~HttpResponseData<SSL>::HTTP_RESPONSE_PENDING;
|
httpResponseData->state &= ~HttpResponseData<SSL>::HTTP_RESPONSE_PENDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called only once per request */
|
||||||
|
void writeMark() {
|
||||||
|
writeHeader("uWebSockets", "v0.15");
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns true on success, indicating that it might be feasible to write more data.
|
/* Returns true on success, indicating that it might be feasible to write more data.
|
||||||
* Will start timeout if stream reaches totalSize or write failure. */
|
* Will start timeout if stream reaches totalSize or write failure. */
|
||||||
bool internalEnd(std::string_view data, int totalSize, bool optional) {
|
bool internalEnd(std::string_view data, int totalSize, bool optional) {
|
||||||
/* Write status if not already done */
|
/* Write status if not already done */
|
||||||
writeStatus(HTTP_200_OK);
|
writeStatus(HTTP_200_OK);
|
||||||
|
|
||||||
/* Write mark, this propagates to WebSockets too */
|
|
||||||
writeHeader("uWebSockets", "v0.15");
|
|
||||||
|
|
||||||
/* If no total size given then assume this chunk is everything */
|
/* If no total size given then assume this chunk is everything */
|
||||||
if (!totalSize) {
|
if (!totalSize) {
|
||||||
totalSize = data.length();
|
totalSize = data.length();
|
||||||
@@ -115,6 +117,9 @@ private:
|
|||||||
} else {
|
} else {
|
||||||
/* Write content-length on first call */
|
/* Write content-length on first call */
|
||||||
if (!(httpResponseData->state & HttpResponseData<SSL>::HTTP_END_CALLED)) {
|
if (!(httpResponseData->state & HttpResponseData<SSL>::HTTP_END_CALLED)) {
|
||||||
|
/* Write mark, this propagates to WebSockets too */
|
||||||
|
writeMark();
|
||||||
|
|
||||||
/* Ending with no response should not leave any content-length */
|
/* Ending with no response should not leave any content-length */
|
||||||
if (totalSize) {
|
if (totalSize) {
|
||||||
/* We have a known send size */
|
/* We have a known send size */
|
||||||
@@ -221,6 +226,9 @@ public:
|
|||||||
HttpResponseData<SSL> *httpResponseData = getHttpResponseData();
|
HttpResponseData<SSL> *httpResponseData = getHttpResponseData();
|
||||||
|
|
||||||
if (!(httpResponseData->state & HttpResponseData<SSL>::HTTP_WRITE_CALLED)) {
|
if (!(httpResponseData->state & HttpResponseData<SSL>::HTTP_WRITE_CALLED)) {
|
||||||
|
/* Write mark on first call to write */
|
||||||
|
writeMark();
|
||||||
|
|
||||||
writeHeader("Transfer-Encoding", "chunked");
|
writeHeader("Transfer-Encoding", "chunked");
|
||||||
httpResponseData->state |= HttpResponseData<SSL>::HTTP_WRITE_CALLED;
|
httpResponseData->state |= HttpResponseData<SSL>::HTTP_WRITE_CALLED;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user