diff --git a/CHANGELOG.md b/CHANGELOG.md
index ecde73a9..f84ebee9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,12 @@
+1.0.0-b20
+
+API Changes:
+
+* Rename HTTP identifiers
+
+--------------------------------------------------------------------------------
+
+>>>>>>> b152207... .
1.0.0-b19
* Boost library min/max guidance
diff --git a/doc/design.qbk b/doc/design.qbk
index c3947d6b..698c6c80 100644
--- a/doc/design.qbk
+++ b/doc/design.qbk
@@ -447,17 +447,16 @@ start. Other design goals:
or frame data, which is of any type meeting the requirements of
__DynamicBuffer__ (modeled after `boost::asio::streambuf`).
- Beast comes with the class `beast::basic_streambuf`, an efficient
- implementation of the [*DynamicBuffer] concept which makes use of multiple
+ Beast comes with the class __basic_streambuf__, an efficient
+ implementation of the __DynamicBuffer__ concept which makes use of multiple
allocated octet arrays. If an incoming message is broken up into
multiple pieces, no reallocation occurs. Instead, new allocations are
appended to the sequence when existing allocations are filled. Beast
does not impose any particular memory management model on callers. The
- `basic_streambuf` provided by beast supports standard allocators through
- a template argument. Use the [*DynamicBuffer] that comes with beast,
+ __basic_streambuf__ provided by beast supports standard allocators through
+ a template argument. Use the __DynamicBuffer__ that comes with beast,
customize the allocator if you desire, or provide your own type that
- meets the
- [@https://github.com/vinniefalco/Beast/blob/6c8b4b2f8dde72b01507e4ac7fde4ffea57ebc99/include/beast/basic_streambuf.hpp#L21 concept requirements].
+ meets the requirements.
[table
[
diff --git a/doc/http.qbk b/doc/http.qbk
index 3553f3ee..8ef784ff 100644
--- a/doc/http.qbk
+++ b/doc/http.qbk
@@ -5,30 +5,62 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
]
+[/
+ideas:
+ - complete send request walkthrough (client)
+ - complete receive response walkthrough (client)
+ - complete receive request walkthrough (server)
+ - complete send response walkthrough (server)
+
+ - Introduce concepts from simple to complex
+ - Smooth progression of new ideas building on the previous ideas
+
+ - do we show a simplified message with collapsed fields?
+ - do we introduce `header` or `message` first?
+
+
+contents:
+ Message (and header, fields)
+ Create request
+ Create response
+ Algorithms
+ Write
+ Read
+ Parse
+ Examples
+ Send Request
+ Receive Response
+ Receive Request
+ Send Response
+ Advanced
+ Responding to HEAD
+ Expect: 100-continue
+ Body (user defined)
+
+
+section beast.http.examples Examples
+
+note
+ In the example code which follows, `socket` refers to an object of type
+ `boost::asio::ip::tcp::socket` which is currently connected to a remote peer.
+]
+
[section:http Using HTTP]
[block '''
- Messages
- Headers
+ Message
+ FieldsBodyAlgorithms
- Sockets
''']
-Beast.HTTP offers programmers simple and performant models of HTTP messages and
+Beast offers programmers simple and performant models of HTTP messages and
their associated operations including synchronous and asynchronous reading and
-writing of messages in the HTTP/1 wire format using Boost.Asio.
-
-A HTTP message (referred to hereafter as "message") contains request or
-response specific attributes, a series of zero or more name/value pairs
-(collectively termed "headers"), and a series of octets called the message
-body which may be zero in length. The HTTP protocol defines the client and
-server roles: clients send messages called requests and servers send back
-messages called responses.
+writing of messages and headers in the HTTP/1 wire format using Boost.Asio.
[note
The following documentation assumes familiarity with both Boost.Asio
@@ -36,6 +68,7 @@ messages called responses.
and identifiers mentioned in this section are written as if the following
declarations are in effect:
```
+ #include
#include
using namespace beast;
using namespace beast::http;
@@ -44,101 +77,124 @@ messages called responses.
-[section:message Messages]
-The __message__ class template models HTTP/1 and HTTP/2 requests and responses.
-These class templates are complete: they contain all the information needed
-by the algorithms. Objects of this type are first class: They may be returned
-from functions, moved, copied, passed as arguments, and stored in containers.
-Request and response messages are distinct types; functions may be overloaded
-on just one or the other if desired. Because this class template supports
-HTTP/1 and HTTP/2, it is sometimes referred to as the universal message model.
-There are three important template parameters in the message class:
+[section:message Message]
+
+The HTTP protocol defines the client and server roles: clients send messages
+called requests and servers send back messages called responses. A HTTP message
+(referred to hereafter as "message") contains request or response specific
+attributes (contained in the "Start Line"), a series of zero or more name/value
+pairs (collectively termed "Fields"), and an optional series of octets called
+the message body which may be zero in length. The start line for a HTTP request
+includes a string called the method, a string called the URL, and a version
+number indicating HTTP/1.0 or HTTP/1.1. For a response, the start line contains
+an integer status code and a string called the reason phrase. Alternatively, a
+HTTP message can be viewed as two parts: a header, followed by a body.
+
+[note
+ The Reason-Phrase is obsolete as of rfc7230.
+]
+
+The __header__ class template models the header for HTTP/1 and HTTP/2 messages.
+This class template is a family of specializations, one for requests and one
+for responses, depending on the [*`isRequest`] template value.
+The [*`Fields`] template type determines the type of associative container
+used to store the field values. The provided __basic_fields__ class template
+and __fields__ type alias are typical choices for the [*`Fields`] type, but
+advanced applications may supply user defined types which meet the requirements.
+The __message__ class template models the header and optional body for HTTP/1
+and HTTP/2 requests and responses. It is derived from the __header__ class
+template with the same shared template parameters, and adds the `body` data
+member. The message class template requires an additional template argument
+type [*`Body`]. This type controls the container used to represent the body,
+if any, as well as the algorithms needed to serialize and parse bodies of
+that type.
+
+This illustration shows the declarations and members of the __header__ and
+__message__ class templates, as well as the inheritance relationship:
+
+[$images/message.png [width 650px] [height 390px]]
+
+For notational convenience, these template type aliases are provided which
+supply typical choices for the [*`Fields`] type:
```
- template<
- bool isRequest,
- class Body,
- class Headers
- >
- class message;
+using request_header = header;
+using response_header = header;
+template
+using request = message;
+
+template
+using response = message;
```
-* [*`isRequest`]: Controls whether or not the message is a request or response.
- Depending on the value, different data members will be present in the resulting
- type.
+The code examples below show how to create and fill in a request and response
+object:
-* [*`Body`]: determines both the kind of container used to represent the
- message body and the algorithms used to parse and serialize it.
-
-* [*`Headers`]: determines the container used to represent the HTTP headers.
-
-For notational convenience, the following template type aliases are provided:
-```
- template<
- class Body,
- class Headers = basic_headers>>
- using request = message;
-
- template<
- class Body,
- class Headers = basic_headers>>
- using response = message;
-```
-
-The message class template has different data members depending on whether
-it represents a request or response. These simplified declarations
-notionally illustrate the members of HTTP/1 messages:
-
-```
- template
- struct request
- {
- int version; // 10 for HTTP/1.0, 11 for HTTP/1.1
- std::string method;
- std::string url;
- Headers headers;
- typename Body::value_type body;
- };
-
- template
- struct response
- {
- int version; // 10 for HTTP/1.0, 11 for HTTP/1.1
- int status;
- std::string reason;
- Headers headers;
- typename Body::value_type body;
- };
-```
-
-These statements set fields in request and response message objects:
-```
- request req;
- req.version = 11; // HTTP/1.1
+[table Create Message
+[[HTTP Request] [HTTP Response]]
+[[
+ ```
+ request req;
+ req.version = 11; // HTTP/1.1
req.method = "GET";
- req.url = "/index.html";
- req.headers.insert("User-Agent", "Beast.HTTP");
- req.body = "";
-
+ req.url = "/index.htm"
+ req.fields.insert("Accept", "text/html");
+ req.fields.insert("Connection", "keep-alive");
+ req.fields.insert("User-Agent", "Beast");
+ ```
+][
+ ```
response res;
- res.version = 10; // HTTP/1.0
- res.status = 404;
- res.reason = "Not Found";
- res.headers.insert("Server", "Beast.HTTP");
- res.body = "The requested resource was not found.";
-```
+ res.version = 11; // HTTP/1.1
+ res.status = 200;
+ res.reason = "OK";
+ res.fields.insert("Sever", "Beast");
+ res.fields.insert("Content-Length", 4);
+ res.body = "****";
+ ```
+]]]
+
+In the serialized format of a HTTP message, the header is represented as a
+series of text lines ending in CRLF (`"\r\n"`). The end of the header is
+indicated by a line containing only CRLF. Here are examples of serialized HTTP
+request and response objects. The objects created above will produce these
+results when serialized. Note that only the response has a body:
+
+[table Serialized HTTP Request and Response
+[[HTTP Request] [HTTP Response]]
+[[
+ ```
+ GET /index.htm HTTP/1.1\r\n
+ Accept: text/html\r\n
+ Connection: keep-alive\r\n
+ User-Agent: Beast\r\n
+ \r\n
+ ```
+][
+ ```
+ 200 OK HTTP/1.1\r\n
+ Server: Beast\r\n
+ Content-Length: 4\r\n
+ \r\n
+ ****
+ ```
+]]]
+
+
+
[endsect]
-[section:headers Headers]
-The [*`Headers`] type represents a container that can set or retrieve the
-headers in a message. Beast provides the
-[link beast.ref.http__basic_headers `basic_headers`] class which serves
+[section:fields Fields]
+
+The [*`Fields`] type represents a container that can set or retrieve the
+fields in a message. Beast provides the
+[link beast.ref.http__basic_fields `basic_fields`] class which serves
the needs for most users. It supports modification and inspection of values.
The field names are not case-sensitive.
@@ -157,15 +213,7 @@ These statements change the values of the headers in the message passed:
}
```
-[heading Advanced]
-
-This illustration shows more detail about the
-[link beast.ref.http__message [*`message`]] class template (boilerplate
-present in the actual declaration has been removed for clarity):
-
-[$images/message.png [width 580px] [height 225px]]
-
-User defined [*`Headers`] types are possible. To support serialization, the
+User defined [*`Fields`] types are possible. To support serialization, the
type must meet the requirements of __FieldSequence__. To support parsing using
the provided parser, the type must provide the `insert` member function.
@@ -233,30 +281,24 @@ serializing message bodies that come from a file.
[section:algorithms Algorithms]
-In addition to the universal message model, Beast provides synchronous
-algorithms which operate on HTTP/1 messages:
+Algorithms are provided to serialize and deserialize HTTP/1 messages on
+streams.
-* [link beast.ref.http__read [*read]]: Parse a message from a stream
-
-* [link beast.ref.http__write [*write]]: Serialize a message into its wire format on a stream
+* [link beast.ref.http__read [*read]]: Deserialize a HTTP/1 __header__ or __message__ from a stream.
+* [link beast.ref.http__write [*write]]: Serialize a HTTP/1 __header__ or __message__ to a stream.
Asynchronous versions of these algorithms are also available:
-* [link beast.ref.http__async_read [*async_read]]: Parse a message from a stream
+* [link beast.ref.http__async_read [*async_read]]: Deserialize a HTTP/1 __header__ or __message__ asynchronously from a stream.
+* [link beast.ref.http__async_write [*async_write]]: Serialize a HTTP/1 __header__ or __message__ asynchronously to a stream.
-* [link beast.ref.http__async_write [*async_write]]: Serialize a message into its wire format on a stream
+[heading Using Sockets]
-[endsect]
-
-
-
-[section:sockets Using Sockets]
-
-The library provides simple free functions modeled after Boost.Asio to
-send and receive messages on TCP/IP sockets, SSL streams, or any object
-which meets the Boost.Asio type requirements (SyncReadStream, SyncWriteStream,
-AsyncReadStream, and AsyncWriteStream depending on the types of operations
-performed). To send messages synchronously, use one of the
+The free function algorithms are modeled after Boost.Asio to send and receive
+messages on TCP/IP sockets, SSL streams, or any object which meets the
+Boost.Asio type requirements (__SyncReadStream__, __SyncWriteStream__,
+__AsyncReadStream__, and __AsyncWriteStream__ depending on the types of
+operations performed). To send messages synchronously, use one of the
[link beast.ref.http__write `write`] functions:
```
void send_request(boost::asio::ip::tcp::socket& sock)
diff --git a/doc/images/message.png b/doc/images/message.png
index cb07efc8..9b88298a 100644
Binary files a/doc/images/message.png and b/doc/images/message.png differ
diff --git a/doc/master.qbk b/doc/master.qbk
index 4075e301..d8155f2d 100644
--- a/doc/master.qbk
+++ b/doc/master.qbk
@@ -23,25 +23,33 @@
[template indexterm1[term1] ''''''[term1]'''''']
[template indexterm2[term1 term2] ''''''[term1]''''''[term2]'''''']
-[def __asio_handler_invoke__ [@http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/asio_handler_invoke.html `asio_handler_invoke`]]
-[def __asio_handler_allocate__ [@http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/asio_handler_allocate.html `asio_handler_allocate`]]
-[def __AsyncReadStream__ [@http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/AsyncReadStream.html [*AsyncReadStream]]]
-[def __AsyncWriteStream__ [@http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/AsyncWriteStream.html [*AsyncWriteStream]]]
-[def __Body__ [link beast.ref.Body [*`Body`]]]
-[def __CompletionHandler__ [@http://www.boost.org/doc/libs/1_60_0/doc/html/boost_asio/reference/CompletionHandler.html [*CompletionHandler]]]
-[def __ConstBufferSequence__ [@http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/ConstBufferSequence.html [*ConstBufferSequence]]]
-[def __DynamicBuffer__ [link beast.ref.DynamicBuffer [*DynamicBuffer]]]
-[def __FieldSequence__ [link beast.ref.FieldSequence [*FieldSequence]]]
-[def __message__ [link beast.ref.http__message `message`]]
-[def __message_v1__ [link beast.ref.http__message_v1 `message_v1`]]
-[def __MutableBufferSequence__ [@http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/MutableBufferSequence.html [*MutableBufferSequence]]]
[def __N4588__ [@http://cplusplus.github.io/networking-ts/draft.pdf [*N4588]]]
[def __rfc6455__ [@https://tools.ietf.org/html/rfc6455 rfc6455]]
[def __rfc7230__ [@https://tools.ietf.org/html/rfc7230 rfc7230]]
-[def __streambuf__ [link beast.ref.streambuf `streambuf`]]
+
+[def __asio_handler_invoke__ [@http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/asio_handler_invoke.html `asio_handler_invoke`]]
+[def __asio_handler_allocate__ [@http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/asio_handler_allocate.html `asio_handler_allocate`]]
+[def __void_or_deduced__ [@http://www.boost.org/doc/libs/1_60_0/doc/html/boost_asio/reference/asynchronous_operations.html#boost_asio.reference.asynchronous_operations.return_type_of_an_initiating_function ['void-or-deduced]]]
+
+[def __AsyncReadStream__ [@http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/AsyncReadStream.html [*AsyncReadStream]]]
+[def __AsyncWriteStream__ [@http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/AsyncWriteStream.html [*AsyncWriteStream]]]
+[def __CompletionHandler__ [@http://www.boost.org/doc/libs/1_60_0/doc/html/boost_asio/reference/CompletionHandler.html [*CompletionHandler]]]
+[def __ConstBufferSequence__ [@http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/ConstBufferSequence.html [*ConstBufferSequence]]]
+[def __MutableBufferSequence__ [@http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/MutableBufferSequence.html [*MutableBufferSequence]]]
[def __SyncReadStream__ [@http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/SyncReadStream.html [*SyncReadStream]]]
[def __SyncWriteStream__ [@http://www.boost.org/doc/libs/1_60_0/doc/html/boost_asio/reference/SyncWriteStream.html [*SyncWriteStream]]]
-[def __void_or_deduced__ [@http://www.boost.org/doc/libs/1_60_0/doc/html/boost_asio/reference/asynchronous_operations.html#boost_asio.reference.asynchronous_operations.return_type_of_an_initiating_function ['void-or-deduced]]]
+
+[def __Body__ [link beast.ref.Body [*`Body`]]]
+[def __DynamicBuffer__ [link beast.ref.DynamicBuffer [*DynamicBuffer]]]
+[def __FieldSequence__ [link beast.ref.FieldSequence [*FieldSequence]]]
+[def __Parser__ [link beast.ref.Parser [*`Parser`]]]
+
+[def __basic_fields__ [link beast.ref.http__basic_fields `basic_fields`]]
+[def __fields__ [link beast.ref.http__fields `fields`]]
+[def __header__ [link beast.ref.http__header `header`]]
+[def __message__ [link beast.ref.http__message `message`]]
+[def __streambuf__ [link beast.ref.streambuf `streambuf`]]
+[def __basic_streambuf__ [link beast.ref.basic_streambuf `basic_streambuf`]]
Beast is a cross-platform, header-only C++ library built on Boost.Asio that
provides implementations of the HTTP and WebSocket protocols.
diff --git a/doc/quickref.xml b/doc/quickref.xml
index 2f75e68a..a51832ba 100644
--- a/doc/quickref.xml
+++ b/doc/quickref.xml
@@ -30,24 +30,25 @@
Classesbasic_dynabuf_body
- basic_headers
+ basic_fieldsbasic_parser_v1empty_body
- headers
- headers_parser_v1
+ fields
+ header
+ header_parser_v1message
- message_headersparser_v1request
- request_headers
+ request_headerresponse
- response_headers
+ response_headerresume_contextstreambuf_bodystring_bodyrfc7230
+
ext_listparam_listtoken_list
@@ -56,20 +57,21 @@
Functions
- async_parseasync_read
+ async_parseasync_writechunk_encodechunk_encode_final
+ swapis_keep_aliveis_upgrade
+ operator<<parseprepareread
- swap
+ reason_stringwith_bodywrite
- operator<<Type Traits
@@ -84,14 +86,17 @@
Options
+ header_max_sizebody_max_size
- headers_max_sizeskip_bodyConstantsbody_whatconnection
+ no_content_length
+ parse_error
+ parse_flagConcepts
diff --git a/examples/file_body.hpp b/examples/file_body.hpp
index 8e7bb55b..c92d4fe7 100644
--- a/examples/file_body.hpp
+++ b/examples/file_body.hpp
@@ -8,9 +8,12 @@
#ifndef BEAST_EXAMPLE_FILE_BODY_H_INCLUDED
#define BEAST_EXAMPLE_FILE_BODY_H_INCLUDED
-#include
+#include
+#include
+#include
#include
#include
+#include
#include
#include
@@ -34,8 +37,8 @@ struct file_body
writer(writer const&) = delete;
writer& operator=(writer const&) = delete;
- template
- writer(message const& m) noexcept
+ template
+ writer(message const& m) noexcept
: path_(m.body)
{
}
diff --git a/examples/http_async_server.hpp b/examples/http_async_server.hpp
index fdc94ef9..350f4a38 100644
--- a/examples/http_async_server.hpp
+++ b/examples/http_async_server.hpp
@@ -85,7 +85,7 @@ public:
private:
template
+ bool isRequest, class Body, class Fields>
class write_op
{
using alloc_type =
@@ -94,13 +94,13 @@ private:
struct data
{
Stream& s;
- message m;
+ message m;
Handler h;
bool cont;
template
data(DeducedHandler&& h_, Stream& s_,
- message&& m_)
+ message&& m_)
: s(s_)
, m(std::move(m_))
, h(std::forward(h_))
@@ -170,16 +170,16 @@ private:
};
template
static
void
async_write(Stream& stream, message<
- isRequest, Body, Headers>&& msg,
+ isRequest, Body, Fields>&& msg,
DeducedHandler&& handler)
{
write_op::type,
- isRequest, Body, Headers>{std::forward(
+ isRequest, Body, Fields>{std::forward(
handler), stream, std::move(msg)};
}
@@ -240,8 +240,8 @@ private:
res.status = 404;
res.reason = "Not Found";
res.version = req_.version;
- res.headers.insert("Server", "http_async_server");
- res.headers.insert("Content-Type", "text/html");
+ res.fields.insert("Server", "http_async_server");
+ res.fields.insert("Content-Type", "text/html");
res.body = "The file '" + path + "' was not found";
prepare(res);
async_write(sock_, std::move(res),
@@ -255,8 +255,8 @@ private:
res.status = 200;
res.reason = "OK";
res.version = req_.version;
- res.headers.insert("Server", "http_async_server");
- res.headers.insert("Content-Type", mime_type(path));
+ res.fields.insert("Server", "http_async_server");
+ res.fields.insert("Content-Type", mime_type(path));
res.body = path;
prepare(res);
async_write(sock_, std::move(res),
@@ -269,8 +269,8 @@ private:
res.status = 500;
res.reason = "Internal Error";
res.version = req_.version;
- res.headers.insert("Server", "http_async_server");
- res.headers.insert("Content-Type", "text/html");
+ res.fields.insert("Server", "http_async_server");
+ res.fields.insert("Content-Type", "text/html");
res.body =
std::string{"An internal error occurred"} + e.what();
prepare(res);
diff --git a/examples/http_crawl.cpp b/examples/http_crawl.cpp
index b968abbb..3e67a14e 100644
--- a/examples/http_crawl.cpp
+++ b/examples/http_crawl.cpp
@@ -40,9 +40,9 @@ int main(int, char const*[])
req.method = "GET";
req.url = "/";
req.version = 11;
- req.headers.insert("Host", host + std::string(":") +
+ req.fields.insert("Host", host + std::string(":") +
boost::lexical_cast(ep.port()));
- req.headers.insert("User-Agent", "beast/http");
+ req.fields.insert("User-Agent", "beast/http");
prepare(req);
write(sock, req);
response res;
diff --git a/examples/http_example.cpp b/examples/http_example.cpp
index 2ccbc3be..55910fee 100644
--- a/examples/http_example.cpp
+++ b/examples/http_example.cpp
@@ -26,9 +26,9 @@ int main()
req.method = "GET";
req.url = "/";
req.version = 11;
- req.headers.replace("Host", host + ":" +
+ req.fields.replace("Host", host + ":" +
boost::lexical_cast(sock.remote_endpoint().port()));
- req.headers.replace("User-Agent", "Beast");
+ req.fields.replace("User-Agent", "Beast");
beast::http::prepare(req);
beast::http::write(sock, req);
diff --git a/examples/http_sync_server.hpp b/examples/http_sync_server.hpp
index 8dfe45d4..bd6df50d 100644
--- a/examples/http_sync_server.hpp
+++ b/examples/http_sync_server.hpp
@@ -168,8 +168,8 @@ private:
res.status = 404;
res.reason = "Not Found";
res.version = req.version;
- res.headers.insert("Server", "http_sync_server");
- res.headers.insert("Content-Type", "text/html");
+ res.fields.insert("Server", "http_sync_server");
+ res.fields.insert("Content-Type", "text/html");
res.body = "The file '" + path + "' was not found";
prepare(res);
write(sock, res, ec);
@@ -183,8 +183,8 @@ private:
res.status = 200;
res.reason = "OK";
res.version = req.version;
- res.headers.insert("Server", "http_sync_server");
- res.headers.insert("Content-Type", mime_type(path));
+ res.fields.insert("Server", "http_sync_server");
+ res.fields.insert("Content-Type", mime_type(path));
res.body = path;
prepare(res);
write(sock, res, ec);
@@ -197,8 +197,8 @@ private:
res.status = 500;
res.reason = "Internal Error";
res.version = req.version;
- res.headers.insert("Server", "http_sync_server");
- res.headers.insert("Content-Type", "text/html");
+ res.fields.insert("Server", "http_sync_server");
+ res.fields.insert("Content-Type", "text/html");
res.body =
std::string{"An internal error occurred: "} + e.what();
prepare(res);
diff --git a/examples/ssl/http_ssl_example.cpp b/examples/ssl/http_ssl_example.cpp
index 09e921cf..ff6224c2 100644
--- a/examples/ssl/http_ssl_example.cpp
+++ b/examples/ssl/http_ssl_example.cpp
@@ -38,9 +38,9 @@ int main()
req.method = "GET";
req.url = "/";
req.version = 11;
- req.headers.insert("Host", host + ":" +
+ req.fields.insert("Host", host + ":" +
boost::lexical_cast(sock.remote_endpoint().port()));
- req.headers.insert("User-Agent", "Beast");
+ req.fields.insert("User-Agent", "Beast");
beast::http::prepare(req);
beast::http::write(stream, req);
diff --git a/include/beast/core/dynabuf_readstream.hpp b/include/beast/core/dynabuf_readstream.hpp
index 458bcc2c..32c545cc 100644
--- a/include/beast/core/dynabuf_readstream.hpp
+++ b/include/beast/core/dynabuf_readstream.hpp
@@ -46,7 +46,7 @@ namespace beast {
Example:
@code
- // Process the next HTTP headers on the stream,
+ // Process the next HTTP header on the stream,
// leaving excess bytes behind for the next call.
//
template
@@ -54,7 +54,7 @@ namespace beast {
dynabuf_readstream& stream)
{
// Read up to and including the end of the HTTP
- // headers, leaving the sequence in the stream's
+ // header, leaving the sequence in the stream's
// buffer. read_until may read past the end of the
// headers; the return value will include only the
// part up to the end of the delimiter.
diff --git a/include/beast/http.hpp b/include/beast/http.hpp
index 02cb4b0d..ee475791 100644
--- a/include/beast/http.hpp
+++ b/include/beast/http.hpp
@@ -8,12 +8,11 @@
#ifndef BEAST_HTTP_HPP
#define BEAST_HTTP_HPP
-#include
+#include
#include
-#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/include/beast/http/basic_dynabuf_body.hpp b/include/beast/http/basic_dynabuf_body.hpp
index 4d331380..de2f43cd 100644
--- a/include/beast/http/basic_dynabuf_body.hpp
+++ b/include/beast/http/basic_dynabuf_body.hpp
@@ -8,9 +8,12 @@
#ifndef BEAST_HTTP_BASIC_DYNABUF_BODY_HPP
#define BEAST_HTTP_BASIC_DYNABUF_BODY_HPP
-#include
+#include
+#include
+#include
#include
#include
+#include
namespace beast {
namespace http {
@@ -34,10 +37,10 @@ private:
value_type& sb_;
public:
- template
+ template
explicit
reader(message& m) noexcept
+ basic_dynabuf_body, Fields>& m) noexcept
: sb_(m.body)
{
}
@@ -63,10 +66,10 @@ private:
DynamicBuffer const& body_;
public:
- template
+ template
explicit
writer(message<
- isRequest, basic_dynabuf_body, Headers> const& m) noexcept
+ isRequest, basic_dynabuf_body, Fields> const& m) noexcept
: body_(m.body)
{
}
diff --git a/include/beast/http/basic_headers.hpp b/include/beast/http/basic_fields.hpp
similarity index 81%
rename from include/beast/http/basic_headers.hpp
rename to include/beast/http/basic_fields.hpp
index b4010196..3bc95774 100644
--- a/include/beast/http/basic_headers.hpp
+++ b/include/beast/http/basic_fields.hpp
@@ -5,11 +5,11 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef BEAST_HTTP_BASIC_HEADERS_HPP
-#define BEAST_HTTP_BASIC_HEADERS_HPP
+#ifndef BEAST_HTTP_BASIC_FIELDS_HPP
+#define BEAST_HTTP_BASIC_FIELDS_HPP
#include
-#include
+#include
#include
#include
#include
@@ -21,35 +21,35 @@
namespace beast {
namespace http {
-/** A container for storing HTTP headers.
+/** A container for storing HTTP header fields.
This container is designed to store the field value pairs that make
- up the headers and trailers in a HTTP message. Objects of this type
- are iterable, which each element holding the field name and field
+ up the fields and trailers in a HTTP message. Objects of this type
+ are iterable, with each element holding the field name and field
value.
- Field names are stored as-is, but comparison are case-insensitive.
+ Field names are stored as-is, but comparisons are case-insensitive.
When the container is iterated, the fields are presented in the order
of insertion. For fields with the same name, the container behaves
- as a std::multiset; there will be a separate value for each occurrence
+ as a `std::multiset`; there will be a separate value for each occurrence
of the field name.
- @note Meets the requirements of @b `FieldSequence`.
+ @note Meets the requirements of @b FieldSequence.
*/
template
-class basic_headers :
+class basic_fields :
#if ! GENERATING_DOCS
private beast::detail::empty_base_optimization<
typename std::allocator_traits::
template rebind_alloc<
- detail::basic_headers_base::element>>,
+ detail::basic_fields_base::element>>,
#endif
- public detail::basic_headers_base
+ public detail::basic_fields_base
{
using alloc_type = typename
std::allocator_traits::
template rebind_alloc<
- detail::basic_headers_base::element>;
+ detail::basic_fields_base::element>;
using alloc_traits =
std::allocator_traits;
@@ -61,16 +61,16 @@ class basic_headers :
delete_all();
void
- move_assign(basic_headers&, std::false_type);
+ move_assign(basic_fields&, std::false_type);
void
- move_assign(basic_headers&, std::true_type);
+ move_assign(basic_fields&, std::true_type);
void
- copy_assign(basic_headers const&, std::false_type);
+ copy_assign(basic_fields const&, std::false_type);
void
- copy_assign(basic_headers const&, std::true_type);
+ copy_assign(basic_fields const&, std::true_type);
template
void
@@ -103,17 +103,17 @@ public:
#endif
/// Default constructor.
- basic_headers() = default;
+ basic_fields() = default;
/// Destructor
- ~basic_headers();
+ ~basic_fields();
- /** Construct the headers.
+ /** Construct the fields.
@param alloc The allocator to use.
*/
explicit
- basic_headers(Allocator const& alloc);
+ basic_fields(Allocator const& alloc);
/** Move constructor.
@@ -121,7 +121,7 @@ public:
@param other The object to move from.
*/
- basic_headers(basic_headers&& other);
+ basic_fields(basic_fields&& other);
/** Move assignment.
@@ -129,25 +129,25 @@ public:
@param other The object to move from.
*/
- basic_headers& operator=(basic_headers&& other);
+ basic_fields& operator=(basic_fields&& other);
/// Copy constructor.
- basic_headers(basic_headers const&);
+ basic_fields(basic_fields const&);
/// Copy assignment.
- basic_headers& operator=(basic_headers const&);
+ basic_fields& operator=(basic_fields const&);
/// Copy constructor.
template
- basic_headers(basic_headers const&);
+ basic_fields(basic_fields const&);
/// Copy assignment.
template
- basic_headers& operator=(basic_headers const&);
+ basic_fields& operator=(basic_fields const&);
/// Construct from a field sequence.
template
- basic_headers(FwdIt first, FwdIt last);
+ basic_fields(FwdIt first, FwdIt last);
/// Returns `true` if the field sequence contains no elements.
bool
@@ -218,7 +218,7 @@ public:
boost::string_ref
operator[](boost::string_ref const& name) const;
- /// Clear the contents of the basic_headers.
+ /// Clear the contents of the basic_fields.
void
clear() noexcept;
@@ -301,6 +301,6 @@ public:
} // http
} // beast
-#include
+#include
#endif
diff --git a/include/beast/http/basic_parser_v1.hpp b/include/beast/http/basic_parser_v1.hpp
index 9db48bf3..70e9e06c 100644
--- a/include/beast/http/basic_parser_v1.hpp
+++ b/include/beast/http/basic_parser_v1.hpp
@@ -22,8 +22,11 @@
namespace beast {
namespace http {
-namespace parse_flag {
-enum values
+/** Parse flags
+
+ The set of parser bit flags are returned by @ref basic_parser_v1::flags.
+*/
+enum parse_flag
{
chunked = 1,
connection_keep_alive = 2,
@@ -34,28 +37,6 @@ enum values
skipbody = 64,
contentlength = 128
};
-} // parse_flag
-
-/** Headers maximum size option.
-
- Sets the maximum number of cumulative bytes allowed
- including all header octets. A value of zero indicates
- no limit on the number of header octets
-
- The default headers maximum size is 16KB (16,384 bytes).
-
- @note Objects of this type are used with basic_parser_v1::set_option.
-*/
-struct headers_max_size
-{
- std::size_t value;
-
- explicit
- headers_max_size(std::size_t v)
- : value(v)
- {
- }
-};
/** Body maximum size option.
@@ -67,7 +48,7 @@ struct headers_max_size
The default body maximum size for requests is 4MB (four
megabytes or 4,194,304 bytes) and unlimited for responses.
- @note Objects of this type are used with basic_parser_v1::set_option.
+ @note Objects of this type are used with @ref basic_parser_v1::set_option.
*/
struct body_max_size
{
@@ -80,9 +61,30 @@ struct body_max_size
}
};
+/** Header maximum size option.
+
+ Sets the maximum number of cumulative bytes allowed
+ including all header octets. A value of zero indicates
+ no limit on the number of header octets.
+
+ The default header maximum size is 16KB (16,384 bytes).
+
+ @note Objects of this type are used with @ref basic_parser_v1::set_option.
+*/
+struct header_max_size
+{
+ std::size_t value;
+
+ explicit
+ header_max_size(std::size_t v)
+ : value(v)
+ {
+ }
+};
+
/** A value indicating how the parser should treat the body.
- This value is returned from the `on_headers` callback in
+ This value is returned from the `on_header` callback in
the derived class. It controls what the parser does next
in terms of the message body.
*/
@@ -94,7 +96,7 @@ enum class body_what
/** Skip parsing of the body.
- When returned by `on_headers` this causes parsing to
+ When returned by `on_header` this causes parsing to
complete and control to return to the caller. This
could be used when sending a response to a HEAD
request, for example.
@@ -116,8 +118,8 @@ enum class body_what
to the parser will begin reading the message body.
This could be used by callers to inspect the HTTP
- headers before committing to read the body. For example,
- to choose the body type based on the headers. Or to
+ header before committing to read the body. For example,
+ to choose the body type based on the fields. Or to
respond to an Expect: 100-continue request.
*/
pause
@@ -181,19 +183,19 @@ static std::uint64_t constexpr no_content_length =
//
void on_value(boost::string_ref const&, error_code&)
- // Called when all the headers have been parsed successfully.
+ // Called when the entire header has been parsed successfully.
//
void
- on_headers(std::uint64_t content_length, error_code&);
+ on_header(std::uint64_t content_length, error_code&);
- // Called after on_headers, before the body is parsed
+ // Called after on_header, before the body is parsed
//
body_what
on_body_what(std::uint64_t content_length, error_code&);
// Called for each piece of the body.
//
- // If the headers indicate chunk encoding, the chunk
+ // If the header indicates chunk encoding, the chunk
// encoding is removed from the buffer before being
// passed to the callback.
//
@@ -319,9 +321,9 @@ public:
std::forward(an)...);
}
- /// Set the headers maximum size option
+ /// Set the header maximum size option
void
- set_option(headers_max_size const& o)
+ set_option(header_max_size const& o)
{
h_max_ = o.value;
h_left_ = h_max_;
@@ -508,7 +510,7 @@ private:
void
init(std::true_type)
{
- // 16KB max headers, 4MB max body
+ // Request: 16KB max header, 4MB max body
h_max_ = 16 * 1024;
b_max_ = 4 * 1024 * 1024;
}
@@ -516,7 +518,7 @@ private:
void
init(std::false_type)
{
- // 16KB max headers, unlimited body
+ // Response: 16KB max header, unlimited body
h_max_ = 16 * 1024;
b_max_ = 0;
}
@@ -616,7 +618,7 @@ private:
template
struct check_on_headers().on_headers(
+ std::declval().on_header(
std::declval(),
std::declval())
)>> : std::true_type {};
@@ -674,7 +676,7 @@ private:
"on_method requirements not met");
if(h_max_ && s.size() > h_left_)
{
- ec = parse_error::headers_too_big;
+ ec = parse_error::header_too_big;
return;
}
h_left_ -= s.size();
@@ -700,7 +702,7 @@ private:
"on_uri requirements not met");
if(h_max_ && s.size() > h_left_)
{
- ec = parse_error::headers_too_big;
+ ec = parse_error::header_too_big;
return;
}
h_left_ -= s.size();
@@ -726,7 +728,7 @@ private:
"on_reason requirements not met");
if(h_max_ && s.size() > h_left_)
{
- ec = parse_error::headers_too_big;
+ ec = parse_error::header_too_big;
return;
}
h_left_ -= s.size();
@@ -785,7 +787,7 @@ private:
"on_field requirements not met");
if(h_max_ && s.size() > h_left_)
{
- ec = parse_error::headers_too_big;
+ ec = parse_error::header_too_big;
return;
}
h_left_ -= s.size();
@@ -799,7 +801,7 @@ private:
"on_value requirements not met");
if(h_max_ && s.size() > h_left_)
{
- ec = parse_error::headers_too_big;
+ ec = parse_error::header_too_big;
return;
}
h_left_ -= s.size();
@@ -810,8 +812,8 @@ private:
call_on_headers(error_code& ec)
{
static_assert(check_on_headers::value,
- "on_headers requirements not met");
- impl().on_headers(content_length_, ec);
+ "on_header requirements not met");
+ impl().on_header(content_length_, ec);
}
body_what
diff --git a/include/beast/http/body_type.hpp b/include/beast/http/body_type.hpp
deleted file mode 100644
index 5b3f9601..00000000
--- a/include/beast/http/body_type.hpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//
-// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot 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)
-//
-
-#ifndef BEAST_HTTP_BODY_TYPE_HPP
-#define BEAST_HTTP_BODY_TYPE_HPP
-
-// Convenience header to include everything
-// needed when declarating a user defined Body type.
-
-#include
-#include
-#include
-#include
-
-#endif
diff --git a/include/beast/http/chunk_encode.hpp b/include/beast/http/chunk_encode.hpp
index 6d9836f2..cb2881b4 100644
--- a/include/beast/http/chunk_encode.hpp
+++ b/include/beast/http/chunk_encode.hpp
@@ -5,10 +5,11 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef BEAST_HTTP_DETAIL_CHUNK_ENCODE_HPP
-#define BEAST_HTTP_DETAIL_CHUNK_ENCODE_HPP
+#ifndef BEAST_HTTP_CHUNK_ENCODE_HPP
+#define BEAST_HTTP_CHUNK_ENCODE_HPP
#include
+#include
#include
#include
#include
@@ -20,92 +21,6 @@
namespace beast {
namespace http {
-class chunk_encode_text
-{
- boost::asio::const_buffer cb_;
-
- // Storage for the longest hex string we might need, plus delimiters.
- std::array buf_;
-
- template
- void
- copy(chunk_encode_text const& other);
-
- template
- void
- setup(std::size_t n);
-
- template
- static
- OutIter
- to_hex(OutIter last, std::size_t n)
- {
- if(n == 0)
- {
- *--last = '0';
- return last;
- }
- while(n)
- {
- *--last = "0123456789abcdef"[n&0xf];
- n>>=4;
- }
- return last;
- }
-
-public:
- using value_type = boost::asio::const_buffer;
-
- using const_iterator = value_type const*;
-
- chunk_encode_text(chunk_encode_text const& other)
- {
- copy(other);
- }
-
- explicit
- chunk_encode_text(std::size_t n)
- {
- setup(n);
- }
-
- const_iterator
- begin() const
- {
- return &cb_;
- }
-
- const_iterator
- end() const
- {
- return begin() + 1;
- }
-};
-template
-void
-chunk_encode_text::
-copy(chunk_encode_text const& other)
-{
- auto const n =
- boost::asio::buffer_size(other.cb_);
- buf_ = other.buf_;
- cb_ = boost::asio::const_buffer(
- &buf_[buf_.size() - n], n);
-}
-
-template
-void
-chunk_encode_text::
-setup(std::size_t n)
-{
- buf_[buf_.size() - 2] = '\r';
- buf_[buf_.size() - 1] = '\n';
- auto it = to_hex(buf_.end() - 2, n);
- cb_ = boost::asio::const_buffer{&*it,
- static_cast(
- std::distance(it, buf_.end()))};
-}
-
/** Returns a chunk-encoded ConstBufferSequence.
This returns a buffer sequence representing the
@@ -124,7 +39,7 @@ template
implementation_defined
#else
beast::detail::buffer_cat_helper<
- chunk_encode_text,
+ detail::chunk_encode_delim,
ConstBufferSequence,
boost::asio::const_buffers_1>
#endif
@@ -132,7 +47,7 @@ chunk_encode(bool fin, ConstBufferSequence const& buffers)
{
using boost::asio::buffer_size;
return buffer_cat(
- chunk_encode_text{buffer_size(buffers)},
+ detail::chunk_encode_delim{buffer_size(buffers)},
buffers,
fin ? boost::asio::const_buffers_1{"\r\n0\r\n\r\n", 7}
: boost::asio::const_buffers_1{"\r\n", 2});
diff --git a/include/beast/http/detail/basic_headers.hpp b/include/beast/http/detail/basic_fields.hpp
similarity index 90%
rename from include/beast/http/detail/basic_headers.hpp
rename to include/beast/http/detail/basic_fields.hpp
index 49bc678d..a60b30f2 100644
--- a/include/beast/http/detail/basic_headers.hpp
+++ b/include/beast/http/detail/basic_fields.hpp
@@ -5,8 +5,8 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef BEAST_HTTP_DETAIL_BASIC_HEADERS_HPP
-#define BEAST_HTTP_DETAIL_BASIC_HEADERS_HPP
+#ifndef BEAST_HTTP_DETAIL_BASIC_FIELDS_HPP
+#define BEAST_HTTP_DETAIL_BASIC_FIELDS_HPP
#include
#include
@@ -17,11 +17,11 @@ namespace beast {
namespace http {
template
-class basic_headers;
+class basic_fields;
namespace detail {
-class basic_headers_base
+class basic_fields_base
{
public:
struct value_type
@@ -51,7 +51,7 @@ public:
protected:
template
- friend class beast::http::basic_headers;
+ friend class beast::http::basic_fields;
struct element
: boost::intrusive::set_base_hook <
@@ -105,7 +105,7 @@ protected:
set_t set_;
list_t list_;
- basic_headers_base(set_t&& set, list_t&& list)
+ basic_fields_base(set_t&& set, list_t&& list)
: set_(std::move(set))
, list_(std::move(list))
{
@@ -116,21 +116,21 @@ public:
using iterator = const_iterator;
- basic_headers_base() = default;
+ basic_fields_base() = default;
};
//------------------------------------------------------------------------------
-class basic_headers_base::const_iterator
+class basic_fields_base::const_iterator
{
using iter_type = list_t::const_iterator;
iter_type it_;
template
- friend class beast::http::basic_headers;
+ friend class beast::http::basic_fields;
- friend class basic_headers_base;
+ friend class basic_fields_base;
const_iterator(iter_type it)
: it_(it)
@@ -139,7 +139,7 @@ class basic_headers_base::const_iterator
public:
using value_type =
- typename basic_headers_base::value_type;
+ typename basic_fields_base::value_type;
using pointer = value_type const*;
using reference = value_type const&;
using difference_type = std::ptrdiff_t;
diff --git a/include/beast/http/detail/chunk_encode.hpp b/include/beast/http/detail/chunk_encode.hpp
new file mode 100644
index 00000000..e2ebb812
--- /dev/null
+++ b/include/beast/http/detail/chunk_encode.hpp
@@ -0,0 +1,111 @@
+//
+// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot 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)
+//
+
+#ifndef BEAST_HTTP_DETAIL_CHUNK_ENCODE_HPP
+#define BEAST_HTTP_DETAIL_CHUNK_ENCODE_HPP
+
+#include
+#include
+#include
+#include
+
+namespace beast {
+namespace http {
+namespace detail {
+
+class chunk_encode_delim
+{
+ boost::asio::const_buffer cb_;
+
+ // Storage for the longest hex string we might need, plus delimiters.
+ std::array buf_;
+
+ template
+ void
+ copy(chunk_encode_delim const& other);
+
+ template
+ void
+ setup(std::size_t n);
+
+ template
+ static
+ OutIter
+ to_hex(OutIter last, std::size_t n)
+ {
+ if(n == 0)
+ {
+ *--last = '0';
+ return last;
+ }
+ while(n)
+ {
+ *--last = "0123456789abcdef"[n&0xf];
+ n>>=4;
+ }
+ return last;
+ }
+
+public:
+ using value_type = boost::asio::const_buffer;
+
+ using const_iterator = value_type const*;
+
+ chunk_encode_delim(chunk_encode_delim const& other)
+ {
+ copy(other);
+ }
+
+ explicit
+ chunk_encode_delim(std::size_t n)
+ {
+ setup(n);
+ }
+
+ const_iterator
+ begin() const
+ {
+ return &cb_;
+ }
+
+ const_iterator
+ end() const
+ {
+ return begin() + 1;
+ }
+};
+
+template
+void
+chunk_encode_delim::
+copy(chunk_encode_delim const& other)
+{
+ auto const n =
+ boost::asio::buffer_size(other.cb_);
+ buf_ = other.buf_;
+ cb_ = boost::asio::const_buffer(
+ &buf_[buf_.size() - n], n);
+}
+
+template
+void
+chunk_encode_delim::
+setup(std::size_t n)
+{
+ buf_[buf_.size() - 2] = '\r';
+ buf_[buf_.size() - 1] = '\n';
+ auto it = to_hex(buf_.end() - 2, n);
+ cb_ = boost::asio::const_buffer{&*it,
+ static_cast(
+ std::distance(it, buf_.end()))};
+}
+
+} // detail
+} // http
+} // beast
+
+#endif
diff --git a/include/beast/http/empty_body.hpp b/include/beast/http/empty_body.hpp
index b76e02d7..e497b87f 100644
--- a/include/beast/http/empty_body.hpp
+++ b/include/beast/http/empty_body.hpp
@@ -8,9 +8,12 @@
#ifndef BEAST_HTTP_EMPTY_BODY_HPP
#define BEAST_HTTP_EMPTY_BODY_HPP
-#include
+#include
+#include
+#include
#include
#include
+#include
#include
#include
@@ -36,9 +39,9 @@ private:
struct writer
{
- template
+ template
explicit
- writer(message const& m) noexcept
+ writer(message const& m) noexcept
{
beast::detail::ignore_unused(m);
}
diff --git a/include/beast/http/headers.hpp b/include/beast/http/fields.hpp
similarity index 62%
rename from include/beast/http/headers.hpp
rename to include/beast/http/fields.hpp
index 3268fa50..fb80ad7f 100644
--- a/include/beast/http/headers.hpp
+++ b/include/beast/http/fields.hpp
@@ -5,17 +5,18 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef BEAST_HTTP_HEADERS_HPP
-#define BEAST_HTTP_HEADERS_HPP
+#ifndef BEAST_HTTP_FIELDS_HPP
+#define BEAST_HTTP_FIELDS_HPP
-#include
+#include
#include
namespace beast {
namespace http {
-using headers =
- basic_headers>;
+/// A typical HTTP header fields container
+using fields =
+ basic_fields>;
} // http
} // beast
diff --git a/include/beast/http/headers_parser_v1.hpp b/include/beast/http/header_parser_v1.hpp
similarity index 74%
rename from include/beast/http/headers_parser_v1.hpp
rename to include/beast/http/header_parser_v1.hpp
index 21236fd5..9caafa44 100644
--- a/include/beast/http/headers_parser_v1.hpp
+++ b/include/beast/http/header_parser_v1.hpp
@@ -13,7 +13,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -36,100 +35,99 @@ struct response_parser_base
} // detail
-/** A parser for HTTP/1 request and response headers.
+/** A parser for a HTTP/1 request or response header.
This class uses the HTTP/1 wire format parser to
- convert a series of octets into a @ref request_headers
- or @ref response_headers.
+ convert a series of octets into a request or
+ response @ref header.
@note A new instance of the parser is required for each message.
*/
-template
-class headers_parser_v1
+template
+class header_parser_v1
: public basic_parser_v1>
+ header_parser_v1>
, private std::conditional::type
{
public:
- /// The type of message this parser produces.
- using headers_type =
- message_headers;
+ /// The type of the header this parser produces.
+ using header_type = header;
private:
- // VFALCO Check Headers requirements?
+ // VFALCO Check Fields requirements?
std::string field_;
std::string value_;
- headers_type h_;
+ header_type h_;
bool flush_ = false;
public:
/// Default constructor
- headers_parser_v1() = default;
+ header_parser_v1() = default;
/// Move constructor
- headers_parser_v1(headers_parser_v1&&) = default;
+ header_parser_v1(header_parser_v1&&) = default;
/// Copy constructor (disallowed)
- headers_parser_v1(headers_parser_v1 const&) = delete;
+ header_parser_v1(header_parser_v1 const&) = delete;
/// Move assignment (disallowed)
- headers_parser_v1& operator=(headers_parser_v1&&) = delete;
+ header_parser_v1& operator=(header_parser_v1&&) = delete;
/// Copy assignment (disallowed)
- headers_parser_v1& operator=(headers_parser_v1 const&) = delete;
+ header_parser_v1& operator=(header_parser_v1 const&) = delete;
/** Construct the parser.
- @param args Forwarded to the message headers constructor.
+ @param args Forwarded to the header constructor.
*/
#if GENERATING_DOCS
template
explicit
- headers_parser_v1(Args&&... args);
+ header_parser_v1(Args&&... args);
#else
template::type, headers_parser_v1>::value>>
+ typename std::decay::type, header_parser_v1>::value>>
explicit
- headers_parser_v1(Arg1&& arg1, ArgN&&... argn)
+ header_parser_v1(Arg1&& arg1, ArgN&&... argn)
: h_(std::forward(arg1),
std::forward(argn)...)
{
}
#endif
- /** Returns the parsed headers.
+ /** Returns the parsed header
Only valid if @ref complete would return `true`.
*/
- headers_type const&
+ header_type const&
get() const
{
return h_;
}
- /** Returns the parsed headers.
+ /** Returns the parsed header.
Only valid if @ref complete would return `true`.
*/
- headers_type&
+ header_type&
get()
{
return h_;
}
- /** Returns ownership of the parsed headers.
+ /** Returns ownership of the parsed header.
Ownership is transferred to the caller. Only
valid if @ref complete would return `true`.
Requires:
- `message_headers` is @b MoveConstructible
+ @ref header_type is @b MoveConstructible
*/
- headers_type
+ header_type
release()
{
static_assert(std::is_move_constructible::value,
@@ -138,7 +136,7 @@ public:
}
private:
- friend class basic_parser_v1;
+ friend class basic_parser_v1;
void flush()
{
@@ -146,7 +144,7 @@ private:
return;
flush_ = false;
BOOST_ASSERT(! field_.empty());
- h_.headers.insert(field_, value_);
+ h_.fields.insert(field_, value_);
field_.clear();
value_.clear();
}
@@ -207,7 +205,7 @@ private:
}
void
- on_headers(std::uint64_t, error_code&)
+ on_header(std::uint64_t, error_code&)
{
flush();
h_.version = 10 * this->http_major() + this->http_minor();
diff --git a/include/beast/http/impl/basic_headers.ipp b/include/beast/http/impl/basic_fields.ipp
similarity index 76%
rename from include/beast/http/impl/basic_headers.ipp
rename to include/beast/http/impl/basic_fields.ipp
index 1186731b..8c421e9e 100644
--- a/include/beast/http/impl/basic_headers.ipp
+++ b/include/beast/http/impl/basic_fields.ipp
@@ -5,8 +5,8 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef BEAST_HTTP_IMPL_BASIC_HEADERS_IPP
-#define BEAST_HTTP_IMPL_BASIC_HEADERS_IPP
+#ifndef BEAST_HTTP_IMPL_BASIC_FIELDS_IPP
+#define BEAST_HTTP_IMPL_BASIC_FIELDS_IPP
#include
#include
@@ -16,7 +16,7 @@ namespace http {
template
void
-basic_headers::
+basic_fields::
delete_all()
{
for(auto it = list_.begin(); it != list_.end();)
@@ -31,8 +31,8 @@ delete_all()
template
inline
void
-basic_headers::
-move_assign(basic_headers& other, std::false_type)
+basic_fields::
+move_assign(basic_fields& other, std::false_type)
{
if(this->member() != other.member())
{
@@ -49,8 +49,8 @@ move_assign(basic_headers& other, std::false_type)
template
inline
void
-basic_headers::
-move_assign(basic_headers& other, std::true_type)
+basic_fields::
+move_assign(basic_fields& other, std::true_type)
{
this->member() = std::move(other.member());
set_ = std::move(other.set_);
@@ -60,8 +60,8 @@ move_assign(basic_headers& other, std::true_type)
template
inline
void
-basic_headers::
-copy_assign(basic_headers const& other, std::false_type)
+basic_fields::
+copy_assign(basic_fields const& other, std::false_type)
{
copy_from(other);
}
@@ -69,8 +69,8 @@ copy_assign(basic_headers const& other, std::false_type)
template
inline
void
-basic_headers::
-copy_assign(basic_headers const& other, std::true_type)
+basic_fields::
+copy_assign(basic_fields const& other, std::true_type)
{
this->member() = other.member();
copy_from(other);
@@ -79,35 +79,35 @@ copy_assign(basic_headers const& other, std::true_type)
//------------------------------------------------------------------------------
template
-basic_headers::
-~basic_headers()
+basic_fields::
+~basic_fields()
{
delete_all();
}
template
-basic_headers::
-basic_headers(Allocator const& alloc)
+basic_fields::
+basic_fields(Allocator const& alloc)
: beast::detail::empty_base_optimization<
alloc_type>(alloc)
{
}
template
-basic_headers::
-basic_headers(basic_headers&& other)
+basic_fields::
+basic_fields(basic_fields&& other)
: beast::detail::empty_base_optimization(
std::move(other.member()))
- , detail::basic_headers_base(
+ , detail::basic_fields_base(
std::move(other.set_), std::move(other.list_))
{
}
template
auto
-basic_headers::
-operator=(basic_headers&& other) ->
- basic_headers&
+basic_fields::
+operator=(basic_fields&& other) ->
+ basic_fields&
{
if(this == &other)
return *this;
@@ -118,9 +118,9 @@ operator=(basic_headers&& other) ->
}
template
-basic_headers::
-basic_headers(basic_headers const& other)
- : basic_headers(alloc_traits::
+basic_fields::
+basic_fields(basic_fields const& other)
+ : basic_fields(alloc_traits::
select_on_container_copy_construction(other.member()))
{
copy_from(other);
@@ -128,9 +128,9 @@ basic_headers(basic_headers const& other)
template
auto
-basic_headers::
-operator=(basic_headers const& other) ->
- basic_headers&
+basic_fields::
+operator=(basic_fields const& other) ->
+ basic_fields&
{
clear();
copy_assign(other, std::integral_constant
template
template
-basic_headers::
-basic_headers(basic_headers const& other)
+basic_fields::
+basic_fields(basic_fields const& other)
{
copy_from(other);
}
@@ -149,9 +149,9 @@ basic_headers(basic_headers const& other)
template
template
auto
-basic_headers::
-operator=(basic_headers const& other) ->
- basic_headers&
+basic_fields::
+operator=(basic_fields const& other) ->
+ basic_fields&
{
clear();
copy_from(other);
@@ -160,8 +160,8 @@ operator=(basic_headers const& other) ->
template
template
-basic_headers::
-basic_headers(FwdIt first, FwdIt last)
+basic_fields::
+basic_fields(FwdIt first, FwdIt last)
{
for(;first != last; ++first)
insert(first->name(), first->value());
@@ -169,7 +169,7 @@ basic_headers(FwdIt first, FwdIt last)
template
std::size_t
-basic_headers::
+basic_fields::
count(boost::string_ref const& name) const
{
auto const it = set_.find(name, less{});
@@ -181,7 +181,7 @@ count(boost::string_ref const& name) const
template
auto
-basic_headers::
+basic_fields::
find(boost::string_ref const& name) const ->
iterator
{
@@ -193,7 +193,7 @@ find(boost::string_ref const& name) const ->
template
boost::string_ref
-basic_headers::
+basic_fields::
operator[](boost::string_ref const& name) const
{
auto const it = find(name);
@@ -204,7 +204,7 @@ operator[](boost::string_ref const& name) const
template
void
-basic_headers::
+basic_fields::
clear() noexcept
{
delete_all();
@@ -214,7 +214,7 @@ clear() noexcept
template
std::size_t
-basic_headers::
+basic_fields::
erase(boost::string_ref const& name)
{
auto it = set_.find(name, less{});
@@ -238,7 +238,7 @@ erase(boost::string_ref const& name)
template
void
-basic_headers::
+basic_fields::
insert(boost::string_ref const& name,
boost::string_ref value)
{
@@ -251,7 +251,7 @@ insert(boost::string_ref const& name,
template
void
-basic_headers::
+basic_fields::
replace(boost::string_ref const& name,
boost::string_ref value)
{
diff --git a/include/beast/http/impl/basic_parser_v1.ipp b/include/beast/http/impl/basic_parser_v1.ipp
index 069656b7..9757b92a 100644
--- a/include/beast/http/impl/basic_parser_v1.ipp
+++ b/include/beast/http/impl/basic_parser_v1.ipp
@@ -5,6 +5,16 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
+#ifndef BEAST_HTTP_IMPL_BASIC_PARSER_V1_IPP
+#define BEAST_HTTP_IMPL_BASIC_PARSER_V1_IPP
+
+#include
+#include
+#include