Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing operators and ctors for http_request and http_response #1668

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 115 additions & 2 deletions Release/include/cpprest/http_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,8 @@ class _http_response final : public http::details::http_msg_base

_http_response(http::status_code code) : m_status_code(code) {}

virtual _http_response() = default;

http::status_code status_code() const { return m_status_code; }

void set_status_code(http::status_code code) { m_status_code = code; }
Expand Down Expand Up @@ -548,6 +550,60 @@ class http_response
/// <returns>A new HTTP response.</returns>
http_response(http::status_code code) : _m_impl(std::make_shared<details::_http_response>(code)) {}

/// <summary>
/// Constructs a response object
/// </summary>
/// <returns>A new HTTP response.</returns>
http_response(const http_response& _Other) : _m_impl(_Other._m_impl) {}

/// <summary>
/// Constructs a response object
/// </summary>
/// <returns>A new HTTP response.</returns>
http_response(http_response&& _Other) : _m_impl(std::move(_Other._m_impl)) {}

/// <summary>Replaces the contents of one <c>http_request</c> object with another.</summary>
/// <param name="_Other">The source <c>http_request</c> object.</param>
/// <remarks>
/// As <c>http_request</c> behaves like a smart pointer, after a copy assignment, this <c>http_request</c>
/// objects represents the same actual http_request as <paramref name="_Other"/> does.
/// </remarks>
/// <returns>A new HTTP response.</returns>
http_response& operator=(const http_response& _Other)
{
if (this != &_Other)
{
_m_impl = _Other._m_impl;
}
return *this;
}

/// <summary>
/// Destructor frees any held resources.
/// </summary>
~http_response() = default;

/// <summary>Replaces the contents of one <c>http_request</c> object with another.</summary>
/// <param name="_Other">The source <c>http_request</c> object.</param>
/// <remarks>
/// As <c>http_request</c> behaves like a smart pointer, after a copy assignment, this <c>http_request</c>
/// objects represents the same actual http_request as <paramref name="_Other"/> does.
/// </remarks>
/// <returns>A new HTTP response.</returns>
http_response& operator=(http_response&& _Other)
{
if (this != &_Other)
{
_m_impl = std::move(_Other._m_impl);
}
return *this;
}

/// <summary>
/// Destructor frees any held resources.
/// </summary>
~http_response() = default;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These don't appear to do anything over just accepting the compiler's defaults. The original class has an empty destructor, which is somewhat redundant, not an excuse to add even more redundant stuff


/// <summary>
/// Gets the status code of the response message.
/// </summary>
Expand Down Expand Up @@ -853,7 +909,7 @@ class _http_request final : public http::details::http_msg_base, public std::ena

_ASYNCRTIMP _http_request(std::unique_ptr<http::details::_http_server_context> server_context);

virtual ~_http_request() {}
virtual ~_http_request() = default;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?


http::method& method() { return m_method; }

Expand Down Expand Up @@ -951,10 +1007,67 @@ class http_request
/// <param name="mtd">Request method.</param>
http_request(http::method mtd) : _m_impl(std::make_shared<http::details::_http_request>(std::move(mtd))) {}

/// <summary>
/// Constructs a <c>http_request</c> object.
/// </summary>
/// <param name="_Other">
/// The source <c>http_request</c> object.
/// </param>
http_request(const http_request& _Other) : _m_impl(_Other._m_impl) {}

/// <summary>
/// Constructs a <c>http_request</c> object.
/// </summary>
/// <param name="_Other">
/// The source <c>http_request</c> object.
/// </param>
http_request(http_request&& _Other) : _m_impl(_Other._m_impl) {}


/// <summary>
/// Replaces the contents of one <c>http_request</c> object with another.
/// </summary>
/// <param name="_Other">
/// The source <c>http_request</c> object.
/// </param>
/// <remarks>
/// As <c>http_request</c> behaves like a smart pointer, after a copy assignment, this <c>http_request</c>
/// objects represents the same actual http_request as <paramref name="_Other"/> does.
/// </remarks>
/**/
http_request& operator=(const http_request& _Other)
{
if (this != &_Other)
{
_m_impl = _Other._m_impl;
}
return *this;
}

/// <summary>
/// Replaces the contents of one <c>http_request</c> object with another.
/// </summary>
/// <param name="_Other">
/// The source <c>http_request</c> object.
/// </param>
/// <remarks>
/// As <c>http_request</c> behaves like a smart pointer, after a copy assignment, this <c>http_request</c>
/// objects represents the same actual http_request as <paramref name="_Other"/> does.
/// </remarks>
/**/
http_request& operator=(http_request&& _Other)
{
if (this != &_Other)
{
_m_impl = std::move(_Other._m_impl);
}
return *this;
}

/// <summary>
/// Destructor frees any held resources.
/// </summary>
~http_request() {}
~http_request() = default;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again not needed


/// <summary>
/// Get the method (GET/PUT/POST/DELETE) of the request message.
Expand Down