Refactor treatment of status code and obsolete reason (API Change):

fix #398

A new enum status is added for the status code.

The function obsolete_reason returns default reason phrasing.

If a response has an empty reason, the serializer will
automatically insert the default reason phrase for the
status code.
This commit is contained in:
Vinnie Falco committed 2017-07-20 08:12:17 -07:00
1 parent f7211da154
commit e5cfe9c11f
14 files changed
+333 -108

No files matched your search

+8 -1
View File
@@ -9,9 +9,11 @@
#define BEAST_HTTP_IMPL_SERIALIZER_IPP
#include <beast/http/error.hpp>
#include <beast/http/status.hpp>
#include <boost/assert.hpp>
#include <ostream>
namespace beast {
namespace http {
namespace detail {
@@ -41,7 +43,12 @@ write_start_line(std::ostream& os,
case 10: os << "HTTP/1.0 "; break;
case 11: os << "HTTP/1.1 "; break;
}
os << msg.status << " " << msg.reason() << "\r\n";
auto const reason = msg.reason();
if(reason.empty())
os << msg.status << " " << msg.reason() << "\r\n";
else
os << msg.status << " " <<
obsolete_reason(static_cast<status>(msg.status)) << "\r\n";
}
template<class FieldSequence>