#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() const
{
    return unsigned(mBody.length());
}

std::string HttpResponse::GetHeaderString() const
{
    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() const
{
    return GetHeaderString() + "\n\n" + mBody;
}
