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
2 changes: 1 addition & 1 deletion cmake/toolchains/gcc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
include(${CMAKE_CURRENT_LIST_DIR}/common.cmake)

# Compiler options.
add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter)
add_compile_options(-Wall -Wextra -Wpedantic)
3 changes: 3 additions & 0 deletions include/boost/http_proto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#include <boost/http_proto/serializer.hpp>
#include <boost/http_proto/sink.hpp>
#include <boost/http_proto/source.hpp>
#include <boost/http_proto/static_fields.hpp>
#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>
Expand Down
10 changes: 6 additions & 4 deletions include/boost/http_proto/detail/header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ struct empty

struct header
{
// this field lookup table is
// stored at the end of the
// allocated buffer, in
// reverse order.
// +------------+-----------+--------------+------------------------------+
// | start-line | headers | free space | entry[count-1] ... entry[0] |
// +------------+-----------+--------------+------------------------------+
// ^ ^ ^ ^
// buf buf+prefix buf+size buf+cap

struct entry
{
offset_type np; // name pos
Expand Down
4 changes: 2 additions & 2 deletions include/boost/http_proto/detail/impl/workspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct workspace::any
};

template<class U>
struct alignas(alignof(::max_align_t))
struct alignas(::max_align_t)
workspace::any_impl : any
{
U u;
Expand Down Expand Up @@ -117,7 +117,7 @@ push_array(
std::size_t n,
T const& t)
{
struct alignas(alignof(::max_align_t))
struct alignas(::max_align_t)
U : any
{
std::size_t n_ = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/boost/http_proto/detail/sv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace detail {
namespace string_literals {
inline
core::string_view
operator"" _sv(
operator""_sv(
char const* p,
std::size_t n) noexcept
{
Expand Down
60 changes: 54 additions & 6 deletions include/boost/http_proto/fields_base.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//
// Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.com)
// Copyright (c) 2024 Christian Mazakas
// Copyright (c) 2025 Mohammad Nejati
//
// 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)
Expand Down Expand Up @@ -37,43 +38,90 @@ class fields_base
: public virtual fields_view_base
{
detail::header h_;
bool static_storage = false;

class op_t;
class prefix_op_t
{
fields_base& self_;
offset_type new_prefix_;
char* buf_ = nullptr;

public:
prefix_op_t(
fields_base& self,
std::size_t new_prefix,
core::string_view* s0 = nullptr,
core::string_view* s1 = nullptr);

~prefix_op_t();
};

using entry =
detail::header::entry;
using table =
detail::header::table;

friend class fields;
template<std::size_t>
friend class static_fields;
friend class request_base;
friend class request;
template<std::size_t>
friend class static_request;
friend class response_base;
friend class response;
template<std::size_t>
friend class static_response;
friend class serializer;
friend class message_base;
friend struct detail::header;
friend struct detail::prefix_op;

BOOST_HTTP_PROTO_DECL
explicit
fields_base(
detail::kind) noexcept;

BOOST_HTTP_PROTO_DECL
fields_base(
detail::kind,
std::size_t size);
char*,
std::size_t) noexcept;

BOOST_HTTP_PROTO_DECL
fields_base(
detail::kind,
std::size_t size,
std::size_t max_size);
std::size_t);

BOOST_HTTP_PROTO_DECL
explicit
fields_base(
detail::kind) noexcept;
detail::kind,
std::size_t,
std::size_t);

BOOST_HTTP_PROTO_DECL
fields_base(
detail::kind,
core::string_view);

fields_base(detail::header const&);
BOOST_HTTP_PROTO_DECL
fields_base(
detail::kind,
char*,
std::size_t,
core::string_view);

BOOST_HTTP_PROTO_DECL
explicit
fields_base(
detail::header const&);

BOOST_HTTP_PROTO_DECL
fields_base(
detail::header const&,
char*,
std::size_t);

public:
/** Destructor
Expand Down
2 changes: 2 additions & 0 deletions include/boost/http_proto/fields_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class BOOST_SYMBOL_VISIBLE
: public fields_view_base
{
friend class fields;
template<std::size_t>
friend class static_fields;

#ifndef BOOST_HTTP_PROTO_DOCS
protected:
Expand Down
8 changes: 8 additions & 0 deletions include/boost/http_proto/fields_view_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,21 @@ class fields_view_base
detail::header const* ph_;

friend class fields;
template<std::size_t>
friend class static_fields;
friend class fields_base;
friend class fields_view;
friend class message_base;
friend class message_view_base;
friend class request_base;
friend class request;
template<std::size_t>
friend class static_request;
friend class request_view;
friend class response_base;
friend class response;
template<std::size_t>
friend class static_response;
friend class response_view;
friend class serializer;

Expand Down
38 changes: 35 additions & 3 deletions include/boost/http_proto/message_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class message_base
: public fields_base
, public message_view_base
{
friend class request;
friend class response;
friend class request_base;
friend class response_base;

explicit
message_base(
Expand All @@ -37,6 +37,16 @@ class message_base
{
}

message_base(
detail::kind k,
char* storage,
std::size_t storage_size) noexcept
: fields_view_base(&this->fields_base::h_)
, fields_base(
k, storage, storage_size)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to get rid of constructors should we require all constructors of fields_base to also have the string_view parameter, defaulted to the empty string?

Copy link
Copy Markdown
Collaborator Author

@ashtum ashtum Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll try that.
BTW, this issue will be resolved when we refactor the code to remove message_view_base from the hierarchy of response/request containers.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should do that though, as it results in duplication and I believe a loss of functionality

{
}

message_base(
detail::kind k,
std::size_t storage_size)
Expand Down Expand Up @@ -67,15 +77,37 @@ class message_base
{
}

message_base(
detail::kind k,
char* storage,
std::size_t storage_size,
core::string_view s)
: fields_view_base(
&this->fields_base::h_)
, fields_base(
k, storage, storage_size, s)
{
}

explicit
message_base(
detail::header const& ph) noexcept
detail::header const& ph)
: fields_view_base(
&this->fields_base::h_)
, fields_base(ph)
{
}

message_base(
detail::header const& ph,
char* storage,
std::size_t storage_size)
: fields_view_base(
&this->fields_base::h_)
, fields_base(ph, storage, storage_size)
{
}

public:
//--------------------------------------------
//
Expand Down
Loading
Loading