Initial commit.

This commit is contained in:
jmsgrogan 2020-05-02 08:31:03 +01:00
commit 59c6161fdb
134 changed files with 4751 additions and 0 deletions

View file

@ -0,0 +1,38 @@
#include "HttpResponse.h"
HttpResponse::HttpResponse()
:mHttpVersion("1.1"),
mResponseCode("200 OK"),
mContentType("text/plain"),
mBody()
{
}
HttpResponse::~HttpResponse()
{
}
void HttpResponse::SetBody(const std::string& body)
{
mBody = body;
}
unsigned HttpResponse::GetBodyLength()
{
return mBody.length();
}
std::string HttpResponse::GetHeaderString()
{
std::string header = "HTTP/" + mHttpVersion + " " + mResponseCode + "\n";
header += "Content-Type: " + mContentType + "\n";
header += "Content-Length: " + std::to_string(GetBodyLength()) + "\n";
return header;
}
std::string HttpResponse::ToString()
{
return GetHeaderString() + "\n\n" + mBody;
}

View file

@ -0,0 +1,26 @@
#pragma once
#include <string>
class HttpResponse
{
std::string mHttpVersion;
std::string mResponseCode;
std::string mContentType;
std::string mBody;
public:
HttpResponse();
~HttpResponse();
void SetBody(const std::string& body);
unsigned GetBodyLength();
std::string GetHeaderString();
std::string ToString();
};