diff --git a/.gitignore b/.gitignore index 83849ba8..6af17c0e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ /bin64 /_build* temp +/build/CMakeCache.txt +/build/CMakeFiles/ +/build/DartConfiguration.tcl # Emacs *# diff --git a/doc/modules/ROOT/pages/reference.adoc b/doc/modules/ROOT/pages/reference.adoc index 75fb2387..168ecdca 100644 --- a/doc/modules/ROOT/pages/reference.adoc +++ b/doc/modules/ROOT/pages/reference.adoc @@ -29,7 +29,7 @@ cpp:boost::http_proto::file_source[file_source] cpp:boost::http_proto::header_limits[header_limits] -cpp:boost::http_proto::message_base[message_base] +cpp:boost::http_proto::header[header] cpp:boost::http_proto::metadata[metadata] diff --git a/include/boost/http_proto.hpp b/include/boost/http_proto.hpp index 38dca128..b7e33f3c 100644 --- a/include/boost/http_proto.hpp +++ b/include/boost/http_proto.hpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/boost/http_proto/fields_base.hpp b/include/boost/http_proto/fields_base.hpp index e9c4e4bc..8f777d27 100644 --- a/include/boost/http_proto/fields_base.hpp +++ b/include/boost/http_proto/fields_base.hpp @@ -64,7 +64,7 @@ class fields_base }; friend class fields; - friend class message_base; + friend class header; friend class request_base; friend class request; friend class static_request; diff --git a/include/boost/http_proto/message_base.hpp b/include/boost/http_proto/header.hpp similarity index 96% rename from include/boost/http_proto/message_base.hpp rename to include/boost/http_proto/header.hpp index 24e3a995..e91c638d 100644 --- a/include/boost/http_proto/message_base.hpp +++ b/include/boost/http_proto/header.hpp @@ -8,8 +8,8 @@ // Official repository: https://github.com/cppalliance/http_proto // -#ifndef BOOST_HTTP_PROTO_MESSAGE_BASE_HPP -#define BOOST_HTTP_PROTO_MESSAGE_BASE_HPP +#ifndef BOOST_HTTP_PROTO_HEADER_HPP +#define BOOST_HTTP_PROTO_HEADER_HPP #include #include @@ -19,7 +19,7 @@ namespace boost { namespace http_proto { /** Mixin for modifing common metadata - in HTTP request and response messages. + in HTTP request and response headers. This type is useful for modifying common properties shared by both requests @@ -32,7 +32,7 @@ namespace http_proto { @ref static_request, @ref metadata. */ -class message_base +class header : public fields_base { friend class request_base; diff --git a/include/boost/http_proto/impl/serializer.hpp b/include/boost/http_proto/impl/serializer.hpp index 1613dc6b..a38de8cf 100644 --- a/include/boost/http_proto/impl/serializer.hpp +++ b/include/boost/http_proto/impl/serializer.hpp @@ -117,16 +117,16 @@ template< void serializer:: start( - message_base const& m, + header const& h, ConstBufferSequence&& cbs) { static_assert(buffers::is_const_buffer_sequence< ConstBufferSequence>::value, "ConstBufferSequence type requirements not met"); - start_init(m); + start_init(h); start_buffers( - m, + h, ws().emplace::type>>( std::forward(cbs))); @@ -139,7 +139,7 @@ template< Source& serializer:: start( - message_base const& m, + header const& h, Args&&... args) { static_assert( @@ -149,10 +149,10 @@ start( std::is_constructible::value, "The Source cannot be constructed with the given arguments"); - start_init(m); + start_init(h); auto& source = ws().emplace( std::forward(args)...); - start_source(m, source); + start_source(h, source); return source; } diff --git a/include/boost/http_proto/request_base.hpp b/include/boost/http_proto/request_base.hpp index 450158d3..fe16b68e 100644 --- a/include/boost/http_proto/request_base.hpp +++ b/include/boost/http_proto/request_base.hpp @@ -12,7 +12,7 @@ #define BOOST_HTTP_PROTO_REQUEST_BASE_HPP #include -#include +#include namespace boost { namespace http_proto { @@ -20,31 +20,31 @@ namespace http_proto { /** Mixin for modifing HTTP requests. @see - @ref message_base, + @ref header, @ref request, @ref static_request. */ class request_base - : public message_base + : public header { friend class request; friend class static_request; request_base() noexcept - : message_base(detail::kind::request) + : header(detail::kind::request) { } explicit request_base(core::string_view s) - : message_base(detail::kind::request, s) + : header(detail::kind::request, s) { } request_base( void* storage, std::size_t cap) noexcept - : message_base( + : header( detail::kind::request, storage, cap) { } diff --git a/include/boost/http_proto/response_base.hpp b/include/boost/http_proto/response_base.hpp index 3708b0d9..3e7d6229 100644 --- a/include/boost/http_proto/response_base.hpp +++ b/include/boost/http_proto/response_base.hpp @@ -13,7 +13,7 @@ #define BOOST_HTTP_PROTO_RESPONSE_BASE_HPP #include -#include +#include #include namespace boost { @@ -22,31 +22,31 @@ namespace http_proto { /** Mixin for modifing HTTP responses. @see - @ref message_base, + @ref header, @ref response, @ref static_response. */ class response_base - : public message_base + : public header { friend class response; friend class static_response; response_base() noexcept - : message_base(detail::kind::response) + : header(detail::kind::response) { } explicit response_base(core::string_view s) - : message_base(detail::kind::response, s) + : header(detail::kind::response, s) { } response_base( void* storage, std::size_t cap) noexcept - : message_base( + : header( detail::kind::response, storage, cap) { } diff --git a/include/boost/http_proto/serializer.hpp b/include/boost/http_proto/serializer.hpp index f65f13ad..c9ac4e70 100644 --- a/include/boost/http_proto/serializer.hpp +++ b/include/boost/http_proto/serializer.hpp @@ -27,7 +27,7 @@ namespace boost { namespace http_proto { // Forward declaration -class message_base; +class header; /** A serializer for HTTP/1 messages @@ -161,7 +161,7 @@ class serializer /** Prepare the serializer for a new message without a body. Initializes the serializer with the HTTP - start-line and headers from `m`, and + start-line and headers from `h`, and without a body. @par Preconditions @@ -187,20 +187,20 @@ class serializer insufficient internal buffer space to start the operation. - @param m The message to read the HTTP + @param h The message to read the HTTP start-line and headers from. @see - @ref message_base. + @ref header. */ void BOOST_HTTP_PROTO_DECL - start(message_base const& m); + start(header const& h); /** Prepare the serializer for a new message with a ConstBufferSequence body. Initializes the serializer with the HTTP - start-line and headers from `m`, and the + start-line and headers from `h`, and the provided `buffers` for reading the message body from. @@ -237,7 +237,7 @@ class serializer insufficient internal buffer space to start the operation. - @param m The message to read the HTTP + @param h The message to read the HTTP start-line and headers from. @param buffers One or more buffers @@ -248,7 +248,7 @@ class serializer until @ref is_done returns `true`. @see - @ref message_base. + @ref header. */ template< class ConstBufferSequence, @@ -258,13 +258,13 @@ class serializer > void start( - message_base const& m, + header const& h, ConstBufferSequence&& buffers); /** Prepare the serializer for a new message with a Source body. Initializes the serializer with the - HTTP start-line and headers from `m`, + HTTP start-line and headers from `h`, and constructs a `Source` object to read the message body. @@ -310,7 +310,7 @@ class serializer insufficient internal buffer space to start the operation. - @param m The message to read the HTTP + @param h The message to read the HTTP start-line and headers from. @param args Arguments to be passed to the @@ -321,7 +321,7 @@ class serializer @see @ref source, @ref file_source, - @ref message_base. + @ref header. */ template< class Source, @@ -330,13 +330,13 @@ class serializer is_source::value>::type> Source& start( - message_base const& m, + header const& h, Args&&... args); /** Prepare the serializer for a new message using a stream interface. Initializes the serializer with the HTTP - start-line and headers from `m`, and returns + start-line and headers from `h`, and returns a @ref stream object for reading the body from an external source. @@ -394,7 +394,7 @@ class serializer insufficient internal buffer space to start the operation. - @param m The message to read the HTTP + @param h The message to read the HTTP start-line and headers from. @return A @ref stream object for reading body @@ -402,12 +402,12 @@ class serializer @see @ref stream, - @ref message_base. + @ref header. */ BOOST_HTTP_PROTO_DECL stream start_stream( - message_base const& m); + header const& h); /** Return the output area. @@ -527,18 +527,18 @@ class serializer BOOST_HTTP_PROTO_DECL void start_init( - message_base const&); + header const&); BOOST_HTTP_PROTO_DECL void start_buffers( - message_base const&, + header const&, cbs_gen&); BOOST_HTTP_PROTO_DECL void start_source( - message_base const&, + header const&, source&); impl* impl_; diff --git a/src/message_base.cpp b/src/header.cpp similarity index 97% rename from src/message_base.cpp rename to src/header.cpp index 7f5ace2d..7f3aba03 100644 --- a/src/message_base.cpp +++ b/src/header.cpp @@ -8,7 +8,7 @@ // Official repository: https://github.com/cppalliance/http_proto // -#include +#include #include #include #include @@ -20,7 +20,7 @@ namespace boost { namespace http_proto { void -message_base:: +header:: set_payload_size( std::uint64_t n) { @@ -39,7 +39,7 @@ set_payload_size( } void -message_base:: +header:: set_content_length( std::uint64_t n) { @@ -48,7 +48,7 @@ set_content_length( } void -message_base:: +header:: set_chunked(bool value) { if(value) @@ -70,7 +70,7 @@ set_chunked(bool value) } void -message_base:: +header:: set_keep_alive(bool value) { if(h_.md.connection.ec.failed()) diff --git a/src/serializer.cpp b/src/serializer.cpp index 179cddce..bd679362 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include "src/detail/array_of_const_buffers.hpp" @@ -633,7 +633,7 @@ class serializer::impl void start_init( - message_base const& m) + header const& h) { // Precondition violation if(state_ != state::start) @@ -646,9 +646,9 @@ class serializer::impl // VFALCO what do we do with // metadata error code failures? - // m.h_.md.maybe_throw(); + // h.h_.md.maybe_throw(); - auto const& md = m.metadata(); + auto const& md = h.metadata(); needs_exp100_continue_ = md.expect.is_100_continue; // Transfer-Encoding @@ -701,9 +701,9 @@ class serializer::impl void start_empty( - message_base const& m) + header const& h) { - start_init(m); + start_init(h); style_ = style::empty; prepped_ = make_array( @@ -715,13 +715,13 @@ class serializer::impl if(!filter_) out_finish(); - prepped_.append({ m.h_.cbuf, m.h_.size }); + prepped_.append({ h.h_.cbuf, h.h_.size }); more_input_ = false; } void start_buffers( - message_base const& m, + header const& h, cbs_gen& cbs_gen) { // start_init() already called @@ -738,7 +738,7 @@ class serializer::impl batch_size + // buffers (is_chunked_ ? 2 : 0)); // chunk header + final chunk - prepped_.append({ m.h_.cbuf, m.h_.size }); + prepped_.append({ h.h_.cbuf, h.h_.size }); more_input_ = (batch_size != 0); if(is_chunked_) @@ -767,14 +767,14 @@ class serializer::impl out_init(); - prepped_.append({ m.h_.cbuf, m.h_.size }); + prepped_.append({ h.h_.cbuf, h.h_.size }); tmp_ = {}; more_input_ = true; } void start_source( - message_base const& m, + header const& h, source& source) { // start_init() already called @@ -794,14 +794,14 @@ class serializer::impl out_init(); - prepped_.append({ m.h_.cbuf, m.h_.size }); + prepped_.append({ h.h_.cbuf, h.h_.size }); more_input_ = true; } stream - start_stream(message_base const& m) + start_stream(header const& h) { - start_init(m); + start_init(h); style_ = style::stream; prepped_ = make_array( @@ -817,7 +817,7 @@ class serializer::impl out_init(); - prepped_.append({ m.h_.cbuf, m.h_.size }); + prepped_.append({ h.h_.cbuf, h.h_.size }); more_input_ = true; return stream{ this }; } @@ -961,19 +961,19 @@ reset() noexcept void serializer:: -start(message_base const& m) +start(header const& h) { BOOST_ASSERT(impl_); - impl_->start_empty(m); + impl_->start_empty(h); } auto serializer:: start_stream( - message_base const& m) -> stream + header const& h) -> stream { BOOST_ASSERT(impl_); - return impl_->start_stream(m); + return impl_->start_stream(h); } auto @@ -1013,30 +1013,30 @@ ws() void serializer:: -start_init(message_base const& m) +start_init(header const& h) { BOOST_ASSERT(impl_); - impl_->start_init(m); + impl_->start_init(h); } void serializer:: start_buffers( - message_base const& m, + header const& h, cbs_gen& cbs_gen) { BOOST_ASSERT(impl_); - impl_->start_buffers(m, cbs_gen); + impl_->start_buffers(h, cbs_gen); } void serializer:: start_source( - message_base const& m, + header const& h, source& source) { BOOST_ASSERT(impl_); - impl_->start_source(m, source); + impl_->start_source(h, source); } //------------------------------------------------ diff --git a/test/unit/message_base.cpp b/test/unit/header.cpp similarity index 88% rename from test/unit/message_base.cpp rename to test/unit/header.cpp index 0bbc652b..21e837fd 100644 --- a/test/unit/message_base.cpp +++ b/test/unit/header.cpp @@ -8,4 +8,4 @@ // // Test that header file is self-contained. -#include +#include diff --git a/test/unit/metadata.cpp b/test/unit/metadata.cpp index dc7e66de..611acafc 100644 --- a/test/unit/metadata.cpp +++ b/test/unit/metadata.cpp @@ -138,7 +138,7 @@ struct metadata_test { auto const req = []( core::string_view s, - void(*f)(message_base&), + void(*f)(header&), metadata::connection_t con) { { @@ -157,65 +157,65 @@ struct metadata_test req("GET / HTTP/1.1\r\n" "Connection: /\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_connection, 1, false, false, false }); req("GET / HTTP/1.1\r\n" "Connection: x\r\n" "Connection: /\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_connection, 2, false, false, false }); req("GET / HTTP/1.1\r\n" "Connection: x, /\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_connection, 1, false, false, false }); req("GET / HTTP/1.1\r\n" "Connection: /\r\n" "Connection: /\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_connection, 2, false, false, false }); req("GET / HTTP/1.1\r\n" "Connection: close\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, true, false, false }); req("GET / HTTP/1.1\r\n" "Connection: keep-alive\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, false, true, false }); req("GET / HTTP/1.1\r\n" "Connection: upgrade\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, false, false, true}); req("GET / HTTP/1.1\r\n" "Connection: upgrade, close, keep-alive\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, true, true, true}); req("GET / HTTP/1.1\r\n" "Server: localhost\r\n" "Connection: upgrade, close, keep-alive\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, true, true, true}); //---------------------------------------- req("GET / HTTP/1.1\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.append(field::connection, "close"); }, @@ -223,7 +223,7 @@ struct metadata_test req("GET / HTTP/1.1\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.append(field::connection, "keep-alive"); }, @@ -231,7 +231,7 @@ struct metadata_test req("GET / HTTP/1.1\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.append(field::connection, "upgrade"); }, @@ -239,7 +239,7 @@ struct metadata_test req("GET / HTTP/1.1\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.append(field::connection, "close"); f.append(field::connection, "keep-alive"); @@ -252,7 +252,7 @@ struct metadata_test "Connection: upgrade\r\n" "Connection: keep-alive\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(f.find(field::connection)); }, @@ -263,7 +263,7 @@ struct metadata_test "Connection: close, upgrade\r\n" "Connection: keep-alive\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(field::connection); }, @@ -275,7 +275,7 @@ struct metadata_test { auto const check = []( core::string_view s, - void(*f)(message_base&), + void(*f)(header&), metadata::content_encoding_t ce) { request req(s); @@ -290,21 +290,21 @@ struct metadata_test check( "GET / HTTP/1.1\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 0, content_coding::identity }); check( "GET / HTTP/1.1\r\n" "Content-Encoding: gzip\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, content_coding::gzip }); check( "GET / HTTP/1.1\r\n" "Content-Encoding: gzip, deflate\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, content_coding::unknown }); check( @@ -312,14 +312,14 @@ struct metadata_test "Content-Encoding: gzip\r\n" "Content-Encoding: deflate\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 2, content_coding::unknown }); check( "GET / HTTP/1.1\r\n" "Content-Encoding: bad;\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_content_encoding, 1, content_coding::unknown}); } @@ -328,7 +328,7 @@ struct metadata_test { auto const check = []( core::string_view s, - void(*f)(message_base&), + void(*f)(header&), metadata::content_length_t clen) { request req(s); @@ -344,7 +344,7 @@ struct metadata_test "GET / HTTP/1.1\r\n" "Content-Length: 0,0\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_content_length, 1, 0 }); check( @@ -352,14 +352,14 @@ struct metadata_test "Content-Length: 00\r\n" "Content-Length: 0,0\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_content_length, 2, 0 }); check( "GET / HTTP/1.1\r\n" "Content-Length: 0\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, 0 }); check( @@ -367,7 +367,7 @@ struct metadata_test "Content-Length: 2\r\n" "Content-Length: 2\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 2, 2 }); check( @@ -375,7 +375,7 @@ struct metadata_test "Content-Length: 3\r\n" "Content-Length: 5\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::multiple_content_length, 2, 0 }); //---------------------------------------- @@ -385,7 +385,7 @@ struct metadata_test "Content-Length: 0\r\n" "Content-Length: 42\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(f.find( field::content_length)); @@ -398,7 +398,7 @@ struct metadata_test "Content-Length: 42\r\n" "Content-Length: 42\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(f.find( field::content_length)); @@ -412,7 +412,7 @@ struct metadata_test "Content-Length: 42\r\n" "Content-Length: 42\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(f.find( field::content_length)); @@ -424,7 +424,7 @@ struct metadata_test "GET / HTTP/1.1\r\n" "Content-Length: 42\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(f.find( field::content_length)); @@ -438,7 +438,7 @@ struct metadata_test "Content-Length: 2\r\n" "Content-Length: 3\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(field::content_length); }, @@ -451,7 +451,7 @@ struct metadata_test "Content-Length: 2\r\n" "Content-Length: 2\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(field::content_length); }, @@ -463,7 +463,7 @@ struct metadata_test { auto const check = []( core::string_view s, - void(*f)(message_base&), + void(*f)(header&), metadata::transfer_encoding_t te) { request req(s); @@ -478,21 +478,21 @@ struct metadata_test check( "GET / HTTP/1.1\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 0, false }); check( "GET / HTTP/1.1\r\n" "Transfer-Encoding: chunked\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, true }); check( "GET / HTTP/1.1\r\n" "Transfer-Encoding: chunked, chunked\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_transfer_encoding, 1, false }); check( @@ -500,14 +500,14 @@ struct metadata_test "Transfer-Encoding: chunked\r\n" "Transfer-Encoding: chunked\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_transfer_encoding, 2, false }); check( "GET / HTTP/1.1\r\n" "Transfer-Encoding: chunked, compress\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_transfer_encoding, 1, false}); check( @@ -515,14 +515,14 @@ struct metadata_test "Transfer-Encoding: chunked\r\n" "Transfer-Encoding: compress\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_transfer_encoding, 2, false}); check( "GET / HTTP/1.1\r\n" "Transfer-Encoding: chunked;a=b\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_transfer_encoding, 1, false }); check( @@ -530,42 +530,42 @@ struct metadata_test "Transfer-Encoding: deflate;a=b\r\n" "Transfer-Encoding: chunked\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_transfer_encoding, 2, false }); check( "GET / HTTP/1.1\r\n" "Transfer-Encoding: compress\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, false }); check( "GET / HTTP/1.1\r\n" "Transfer-Encoding: deflate\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, false }); check( "GET / HTTP/1.1\r\n" "Transfer-Encoding: gzip\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, false }); check( "GET / HTTP/1.1\r\n" "Transfer-Encoding: custom;a=1\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, false}); check( "GET / HTTP/1.1\r\n" "Transfer-Encoding: a,b,c\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, false}); check( @@ -573,7 +573,7 @@ struct metadata_test "Transfer-Encoding: a,b,c\r\n" "Transfer-Encoding: x,y\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 2, false}); //---------------------------------------- @@ -582,7 +582,7 @@ struct metadata_test "GET / HTTP/1.1\r\n" "Transfer-Encoding: compress\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(f.find(field::transfer_encoding)); }, @@ -593,7 +593,7 @@ struct metadata_test "Transfer-Encoding: compress\r\n" "Transfer-Encoding: chunked\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(f.find(field::transfer_encoding)); }, @@ -605,7 +605,7 @@ struct metadata_test "Transfer-Encoding: compress\r\n" "Transfer-Encoding: chunked\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(f.find(field::transfer_encoding)); }, @@ -616,7 +616,7 @@ struct metadata_test "Server: localhost\r\n" "Transfer-Encoding: chunked\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(f.find(field::transfer_encoding)); }, @@ -629,7 +629,7 @@ struct metadata_test "Transfer-Encoding: compress\r\n" "Transfer-Encoding: chunked\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(field::transfer_encoding); }, @@ -641,7 +641,7 @@ struct metadata_test { auto const check = []( core::string_view s, - void(*f)(message_base&), + void(*f)(header&), metadata::upgrade_t te) { request req(s); @@ -657,21 +657,21 @@ struct metadata_test "GET / HTTP/1.1\r\n" "Upgrade: websocket\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, true }); check( "GET / HTTP/1.1\r\n" "Upgrade: WEBSOCKET\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, true }); check( "GET / HTTP/1.1\r\n" "Upgrade: /usr\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_upgrade, 1, false }); check( @@ -679,14 +679,14 @@ struct metadata_test "Upgrade: /usr\r\n" "Upgrade: websocket\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_upgrade, 2, false }); check( "GET / HTTP/1.1\r\n" "Upgrade: websocket, /usr\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_upgrade, 1, false }); // HTTP/1.0 @@ -694,14 +694,14 @@ struct metadata_test "GET / HTTP/1.0\r\n" "Upgrade: websocket\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { error::bad_upgrade, 1, false }); check( "GET / HTTP/1.1\r\n" "Upgrade: chaka\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, false }); check( @@ -709,14 +709,14 @@ struct metadata_test "Upgrade: websocket\r\n" "Upgrade: rick/morty\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 2, true }); check( "GET / HTTP/1.1\r\n" "Upgrade: websocket/2\r\n" "\r\n", - [](message_base&){}, + [](header&){}, { ok, 1, false }); //---------------------------------------- @@ -724,7 +724,7 @@ struct metadata_test check( "GET / HTTP/1.1\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.append(field::upgrade, "http/2"); }, @@ -734,7 +734,7 @@ struct metadata_test "GET / HTTP/1.1\r\n" "Upgrade: chaka\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(f.find(field::upgrade)); }, @@ -744,7 +744,7 @@ struct metadata_test "GET / HTTP/1.1\r\n" "Upgrade: websocket\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(f.find(field::upgrade)); }, @@ -753,7 +753,7 @@ struct metadata_test check( "GET / HTTP/1.1\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.append(field::upgrade, "websocket"); f.append(field::upgrade, "chaka"); @@ -764,7 +764,7 @@ struct metadata_test check( "GET / HTTP/1.1\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.append(field::upgrade, "chaka"); f.append(field::upgrade, "websocket"); @@ -778,7 +778,7 @@ struct metadata_test "Upgrade: http/2\r\n" "Upgrade: chaka\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(field::upgrade); }, @@ -790,7 +790,7 @@ struct metadata_test { auto const check = []( core::string_view s, - void(*f)(message_base&), + void(*f)(header&), core::string_view s1) { request req(s); @@ -802,7 +802,7 @@ struct metadata_test "GET / HTTP/1.1\r\n" "Server: localhost\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.append(field::accept, "text/html"); }, @@ -816,7 +816,7 @@ struct metadata_test "Server: localhost\r\n" "Accept: text/html\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(f.find(field::accept)); }, @@ -832,7 +832,7 @@ struct metadata_test "Set-Cookie: 2\r\n" "Set-Cookie: 3\r\n" "\r\n", - [](message_base& f) + [](header& f) { f.erase(field::set_cookie); }, diff --git a/test/unit/request.cpp b/test/unit/request.cpp index 3c008818..3af81dca 100644 --- a/test/unit/request.cpp +++ b/test/unit/request.cpp @@ -11,7 +11,7 @@ // Test that header file is self-contained. #include -#include +#include #include