Refactor http::header contents (API Change):

fix #124

The http::header data members "method", "url", and "reason"
are changed from data members, to pairs of get and set
functions which forward the call to the Fields type used
to instantiate the template.

Previously, these data members were implemented using
std::string. With this change, the implementation of the
Fields type used to instantiate the template is now in
control of the representation of those values. This permits
custom memory allocation strategies including uniform use of
the Allocator type already provided to beast::http::basic_fields.
This commit is contained in:
Vinnie Falco committed 2017-05-07 13:40:04 -07:00
1 parent dd02097d26
commit ff5e659545
30 files changed
+319 -213

No files matched your search

+41
View File
@@ -12,6 +12,7 @@
#include <beast/core/detail/empty_base_optimization.hpp>
#include <beast/http/detail/fields.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/utility/string_ref.hpp>
#include <algorithm>
#include <cctype>
#include <memory>
@@ -297,6 +298,46 @@ public:
replace(name,
boost::lexical_cast<std::string>(value));
}
#if BEAST_DOXYGEN
private:
#endif
boost::string_ref
method() const
{
return (*this)[":method"];
}
void
method(boost::string_ref const& s)
{
return this->replace(":method", s);
}
boost::string_ref
target() const
{
return (*this)[":target"];
}
void
target(boost::string_ref const& s)
{
return this->replace(":target", s);
}
boost::string_ref
reason() const
{
return (*this)[":reason"];
}
void
reason(boost::string_ref const& s)
{
return this->replace(":reason", s);
}
};
/// A typical HTTP header fields container