Initial commit.
This commit is contained in:
commit
59c6161fdb
134 changed files with 4751 additions and 0 deletions
38
src/core/http/HttpResponse.cpp
Normal file
38
src/core/http/HttpResponse.cpp
Normal 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;
|
||||
}
|
26
src/core/http/HttpResponse.h
Normal file
26
src/core/http/HttpResponse.h
Normal 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();
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue