Skip to content

Commit 048f895

Browse files
committed
Removing http_response::error_code(). This API should never have existed in the first place. All errors are communicated via an http_exception with contains a std::error_code.
1 parent 9945076 commit 048f895

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

Release/include/cpprest/http_client_impl.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,14 @@ class request_context
142142
/// </summary>
143143
void complete_request(size_t body_size)
144144
{
145-
m_response.set_error_code(0);
146145
m_response._get_impl()->_complete(body_size);
147146

148147
finish();
149148
}
150149

151150
void report_error(unsigned long error_code, const utility::string_t & errorMessage)
152151
{
153-
m_response.set_error_code(error_code);
154-
report_exception(http_exception((int)m_response.error_code(), errorMessage));
152+
report_exception(http_exception((int)error_code, errorMessage));
155153
}
156154

157155
template<typename _ExceptionType>

Release/include/cpprest/http_msg.h

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -324,18 +324,14 @@ class _http_server_context
324324
class _http_response : public http::details::http_msg_base
325325
{
326326
public:
327-
_http_response() : m_status_code((std::numeric_limits<uint16_t>::max)()), m_error_code(0) { }
327+
_http_response() : m_status_code((std::numeric_limits<uint16_t>::max)()) { }
328328

329-
_http_response(http::status_code code) : m_status_code(code), m_error_code(0) {}
329+
_http_response(http::status_code code) : m_status_code(code) {}
330330

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

333333
void set_status_code(http::status_code code) { m_status_code = code; }
334334

335-
unsigned long error_code() const { return m_error_code; }
336-
337-
void set_error_code(unsigned long code) { m_error_code = code; }
338-
339335
const http::reason_phrase & reason_phrase() const { return m_reason_phrase; }
340336

341337
void set_reason_phrase(http::reason_phrase reason) { m_reason_phrase = std::move(reason); }
@@ -349,8 +345,6 @@ class _http_response : public http::details::http_msg_base
349345
private:
350346
std::unique_ptr<_http_server_context> m_server_context;
351347

352-
unsigned long m_error_code;
353-
354348
http::status_code m_status_code;
355349
http::reason_phrase m_reason_phrase;
356350
};
@@ -596,18 +590,6 @@ class http_response
596590
return pplx::create_task(impl->_get_data_available()).then([impl](utility::size64_t) -> http_response { return http_response(impl); });
597591
}
598592

599-
/// <summary>
600-
/// Gets the error code of the response. This is used for errors other than HTTP status codes.
601-
/// </summary>
602-
/// <returns>The error code.</returns>
603-
unsigned long error_code() const { return _m_impl->error_code(); }
604-
605-
/// <summary>
606-
/// Sets the error code of the response. This is used for errors other than HTTP status codes.
607-
/// </summary>
608-
/// <param name="code">The error code</param>
609-
void set_error_code(unsigned long code) const { _m_impl->set_error_code(code); }
610-
611593
std::shared_ptr<http::details::_http_response> _get_impl() const { return _m_impl; }
612594

613595
http::details::_http_server_context * _get_server_context() const { return _m_impl->_get_server_context(); }
@@ -620,7 +602,6 @@ class http_response
620602
{
621603
}
622604

623-
private:
624605
std::shared_ptr<http::details::_http_response> _m_impl;
625606
};
626607

0 commit comments

Comments
 (0)