i develop a Http server, my Summary of response code is this:
PHTTP_DATA_CHUNK p = new HTTP_DATA_CHUNK[count];
for (int i = 0; i<count; i++)
{
p[i].DataChunkType = HttpDataChunkFromMemory;
p[i].FromMemory.pBuffer = "dfdff";
p[i].FromMemory.BufferLength = 5;
}
HTTP_RESPONSE response;
ZeroMemory(&response,sizeof(HTTP_RESPONSE));
PCSTR Reason="OK";
response.StatusCode=200;
response.pReason=Reason;
response.ReasonLength=strlen(Reason);
ADD_KNOWN_HEADER(response, HttpHeaderContentType, "text/html");
ADD_KNOWN_HEADER(response, HttpHeaderConnection, "keep-alive");
ADD_KNOWN_HEADER(response, HttpHeaderTransferEncoding, "chunked");
ADD_KNOWN_HEADER(response, HttpHeaderContentLength, chLen);
response.EntityChunkCount = count;
response.pEntityChunks=p;
ULONG BytesSent;
ULONG result = HttpSendHttpResponse(ReqQueueHandle, HttpRequest->RequestId,
0, &response, NULL,&BytesSent, NULL,
0,NULL,NULL, NULL);
But the result is 87
!
Now if I remove this line of code:
ADD_KNOWN_HEADER(response, HttpHeaderTransferEncoding, "chunked");
The result is 0
and my response is sent to client.
How I to make use of Chunked transfer encoding
?
When I rearrange the code in the following way, the Response is send correctly: