Added move/copy constructors to Http & HttpResponse

This commit is contained in:
Fred Nicolson 2017-06-16 15:16:13 +01:00
parent 96567f4338
commit aa8509e460
4 changed files with 48 additions and 3 deletions

View File

@ -79,6 +79,8 @@ namespace fr
};
Http();
Http(Http &&);
Http(const Http &);
virtual ~Http() = default;
/*!
@ -280,6 +282,11 @@ namespace fr
*/
std::vector<std::pair<std::string, std::string>> parse_argument_list(const std::string &str);
/*!
* Parses a header line in a HTTP request/response
*
* @param str The header. E.g: header: value
*/
void parse_header_line(const std::string &str);
//Other request info

View File

@ -16,9 +16,10 @@ namespace fr
{
public:
//Constructors
HttpResponse() = default;
HttpResponse(HttpResponse &&other) = default;
virtual ~HttpResponse() = default;
HttpResponse(){};
HttpResponse(HttpResponse &&other);
HttpResponse(const HttpResponse &);
virtual ~HttpResponse(){}
/*!
* Parse a HTTP response.

View File

@ -19,6 +19,29 @@ namespace fr
clear();
}
Http::Http(Http &&o)
: header_data(std::move(o.header_data)),
post_data(std::move(o.post_data)),
get_data(std::move(o.get_data)),
body(std::move(o.body)),
request_type(o.request_type),
uri(std::move(o.uri)),
status(o.status)
{
}
Http::Http(const Http &o)
: header_data(o.header_data),
post_data(o.post_data),
get_data(o.get_data),
body(o.body),
request_type(o.request_type),
uri(o.uri),
status(o.status)
{
}
Http::RequestType Http::get_type() const
{
return request_type;

View File

@ -7,6 +7,20 @@
namespace fr
{
HttpResponse::HttpResponse(HttpResponse &&other)
: header_ended(other.header_ended),
content_length(other.content_length)
{
}
HttpResponse::HttpResponse(const HttpResponse &other)
: header_ended(other.header_ended),
content_length(other.content_length)
{
}
bool HttpResponse::parse(const std::string &response_data)
{
body += response_data;