Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 4 additions & 2 deletions doc/modules/ROOT/pages/reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ cpp:boost::http_proto::response[response]

cpp:boost::http_proto::response_base[response_base]

| **Types (2/2)**

cpp:boost::http_proto::response_parser[response_parser]

| **Types (2/2)**

cpp:boost::http_proto::response_view[response_view]

cpp:boost::http_proto::serializer[serializer]
Expand All @@ -71,6 +71,8 @@ cpp:boost::http_proto::static_request[static_request]

cpp:boost::http_proto::static_response[static_response]

cpp:boost::http_proto::string_body[string_body]

**Functions**

cpp:boost::http_proto::combine_field_values[combine_field_values]
Expand Down
66 changes: 39 additions & 27 deletions doc/tagfiles/boost-http_proto-doxygen.tag.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<class kind="class">boost::http_proto::static_fields</class>
<class kind="class">boost::http_proto::static_request</class>
<class kind="class">boost::http_proto::static_response</class>
<class kind="class">boost::http_proto::string_body</class>
<class kind="class">boost::http_proto::upgrade_protocol</class>
<class kind="class">boost::http_proto::condition</class>
<class kind="class">boost::http_proto::content_coding</class>
Expand Down Expand Up @@ -206,8 +207,8 @@
</member>
<member kind="function">
<type>void</type>
<name>set_max_capacity</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity.adoc</anchorfile>
<name>set_max_capacity_in_bytes</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity_in_bytes.adoc</anchorfile>
<anchor/>
<arglist>(std::size_t n)</arglist>
</member>
Expand Down Expand Up @@ -322,8 +323,8 @@
</member>
<member kind="function">
<type>void</type>
<name>set_max_capacity</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity.adoc</anchorfile>
<name>set_max_capacity_in_bytes</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity_in_bytes.adoc</anchorfile>
<anchor/>
<arglist>(std::size_t n)</arglist>
</member>
Expand Down Expand Up @@ -493,13 +494,6 @@
<compound kind="class">
<name>boost::http_proto::file</name>
<filename>boost/http_proto/file.adoc</filename>
<member kind="function">
<type>void</type>
<name>~file</name>
<anchorfile>boost/http_proto/file/2destructor.adoc</anchorfile>
<anchor/>
<arglist>()</arglist>
</member>
<member kind="function">
<type>file&amp;</type>
<name>operator=</name>
Expand Down Expand Up @@ -735,8 +729,8 @@
</member>
<member kind="function">
<type>void</type>
<name>set_max_capacity</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity.adoc</anchorfile>
<name>set_max_capacity_in_bytes</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity_in_bytes.adoc</anchorfile>
<anchor/>
<arglist>(std::size_t n)</arglist>
</member>
Expand Down Expand Up @@ -1382,8 +1376,8 @@
</member>
<member kind="function">
<type>void</type>
<name>set_max_capacity</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity.adoc</anchorfile>
<name>set_max_capacity_in_bytes</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity_in_bytes.adoc</anchorfile>
<anchor/>
<arglist>(std::size_t n)</arglist>
</member>
Expand Down Expand Up @@ -1603,8 +1597,8 @@
</member>
<member kind="function">
<type>void</type>
<name>set_max_capacity</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity.adoc</anchorfile>
<name>set_max_capacity_in_bytes</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity_in_bytes.adoc</anchorfile>
<anchor/>
<arglist>(std::size_t n)</arglist>
</member>
Expand Down Expand Up @@ -2077,8 +2071,8 @@
</member>
<member kind="function">
<type>void</type>
<name>set_max_capacity</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity.adoc</anchorfile>
<name>set_max_capacity_in_bytes</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity_in_bytes.adoc</anchorfile>
<anchor/>
<arglist>(std::size_t n)</arglist>
</member>
Expand Down Expand Up @@ -2277,8 +2271,8 @@
</member>
<member kind="function">
<type>void</type>
<name>set_max_capacity</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity.adoc</anchorfile>
<name>set_max_capacity_in_bytes</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity_in_bytes.adoc</anchorfile>
<anchor/>
<arglist>(std::size_t n)</arglist>
</member>
Expand Down Expand Up @@ -2840,8 +2834,8 @@
</member>
<member kind="function">
<type>void</type>
<name>set_max_capacity</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity.adoc</anchorfile>
<name>set_max_capacity_in_bytes</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity_in_bytes.adoc</anchorfile>
<anchor/>
<arglist>(std::size_t n)</arglist>
</member>
Expand Down Expand Up @@ -3019,8 +3013,8 @@
</member>
<member kind="function">
<type>void</type>
<name>set_max_capacity</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity.adoc</anchorfile>
<name>set_max_capacity_in_bytes</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity_in_bytes.adoc</anchorfile>
<anchor/>
<arglist>(std::size_t n)</arglist>
</member>
Expand Down Expand Up @@ -3219,8 +3213,8 @@
</member>
<member kind="function">
<type>void</type>
<name>set_max_capacity</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity.adoc</anchorfile>
<name>set_max_capacity_in_bytes</name>
<anchorfile>boost/http_proto/fields_base/set_max_capacity_in_bytes.adoc</anchorfile>
<anchor/>
<arglist>(std::size_t n)</arglist>
</member>
Expand Down Expand Up @@ -3281,6 +3275,24 @@
<arglist>()</arglist>
</member>
</compound>
<compound kind="class">
<name>boost::http_proto::string_body</name>
<filename>boost/http_proto/string_body.adoc</filename>
<member kind="function">
<type>const_iterator</type>
<name>begin</name>
<anchorfile>boost/http_proto/string_body/begin.adoc</anchorfile>
<anchor/>
<arglist>()</arglist>
</member>
<member kind="function">
<type>const_iterator</type>
<name>end</name>
<anchorfile>boost/http_proto/string_body/end.adoc</anchorfile>
<anchor/>
<arglist>()</arglist>
</member>
</compound>
<compound kind="class">
<name>boost::http_proto::upgrade_protocol</name>
<filename>boost/http_proto/upgrade_protocol.adoc</filename>
Expand Down
1 change: 1 addition & 0 deletions include/boost/http_proto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <boost/http_proto/static_request.hpp>
#include <boost/http_proto/static_response.hpp>
#include <boost/http_proto/status.hpp>
#include <boost/http_proto/string_body.hpp>
#include <boost/http_proto/version.hpp>

#include <boost/http_proto/rfc/combine_field_values.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/boost/http_proto/field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ enum class field : unsigned short
*/
BOOST_HTTP_PROTO_DECL
core::string_view
to_string(field f) noexcept;
to_string(field f);

/** Return the field name constant for a header name.

Expand Down
103 changes: 103 additions & 0 deletions include/boost/http_proto/string_body.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
//
// Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/cppalliance/http_proto
//

#ifndef BOOST_HTTP_PROTO_STRING_BODY_HPP
#define BOOST_HTTP_PROTO_STRING_BODY_HPP

#include <boost/http_proto/detail/config.hpp>
#include <boost/buffers/const_buffer.hpp>
#include <string>
#include <utility>

namespace boost {
namespace http_proto {

/** A ConstBufferSequence adapter for an owned `std::string`.

Takes ownership of a `std::string` and exposes
it via an interface conforming to the
ConstBufferSequence requirements.

@par Example
@code
serializer sr(ctx);
response res(status::not_found);

std::string body =
"<html>\n"
" <body>\n"
" <h1>404 Not Found</h1>\n"
" <p>Sorry, the page does not exist.</p>\n"
" </body>\n"
"</html>\n";
sr.start<string_body>(res, std::move(body));
@endcode

@see
@ref serializer.
*/
class string_body
{
std::string s_;
buffers::const_buffer cb_;

public:
/// The type for each buffer.
using value_type = buffers::const_buffer;

/// The type of a const iterator.
using const_iterator = buffers::const_buffer const*;

string_body(
string_body&& other) noexcept
: s_(std::move(other.s_))
, cb_(s_.data(), s_.size())
{
other.cb_ = {};
}

/** Constructor.
*/
string_body(
string_body const& other) = delete;

/** Constructor.

@param s The string to take ownership of.
*/
string_body(
std::string s) noexcept
: s_(std::move(s))
, cb_(s_.data(), s_.size())
{
}

/** Return an iterator to the beginning of the
buffer sequence.
*/
const_iterator
begin() const noexcept
{
return &cb_;
}

/** Return an iterator to the end of the
buffer sequence.
*/
const_iterator
end() const noexcept
{
return &cb_ + 1;
}
};

} // http_proto
} // boost

#endif
2 changes: 1 addition & 1 deletion include/boost/http_proto/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ enum class version : char
*/
BOOST_HTTP_PROTO_DECL
core::string_view
to_string(version v) noexcept;
to_string(version v);

/** Format the version to an output stream.

Expand Down
2 changes: 1 addition & 1 deletion src/field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ get_field_table() noexcept
} // detail

core::string_view
to_string(field f) noexcept
to_string(field f)
{
auto const& v = detail::get_field_table();
BOOST_ASSERT(static_cast<unsigned>(f) < v.size());
Expand Down
2 changes: 1 addition & 1 deletion src/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace http_proto {

core::string_view
to_string(
version v) noexcept
version v)
{
switch(v)
{
Expand Down
Loading