34 lines
No EOL
1.1 KiB
C++
34 lines
No EOL
1.1 KiB
C++
#include "Win32WebResponse.h"
|
|
|
|
#include "HttpResponse.h"
|
|
|
|
Win32WebResponse::Win32WebResponse(const HttpResponse& response)
|
|
{
|
|
RtlZeroMemory((&mResponse), sizeof(*(&mResponse)));
|
|
mResponse.StatusCode = response.getStatusCode();
|
|
|
|
std::string reason = response.getResponseReason();
|
|
mResponse.pReason = reason.c_str();
|
|
mResponse.ReasonLength = (USHORT)strlen(reason.c_str());
|
|
|
|
const std::string content_type = "text / html";
|
|
mResponse.Headers.KnownHeaders[HttpHeaderContentType].pRawValue = content_type.c_str();
|
|
mResponse.Headers.KnownHeaders[HttpHeaderContentType].RawValueLength = (USHORT)strlen(content_type.c_str());
|
|
|
|
auto body = response.getBody();
|
|
if (!body.empty())
|
|
{
|
|
HTTP_DATA_CHUNK dataChunk;
|
|
dataChunk.DataChunkType = HttpDataChunkFromMemory;
|
|
dataChunk.FromMemory.pBuffer = body.data();
|
|
dataChunk.FromMemory.BufferLength = (ULONG)strlen(body.data());
|
|
|
|
mResponse.EntityChunkCount = 1;
|
|
mResponse.pEntityChunks = &dataChunk;
|
|
}
|
|
}
|
|
|
|
HTTP_RESPONSE& Win32WebResponse::getResponse()
|
|
{
|
|
return mResponse;
|
|
} |