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
8 changes: 0 additions & 8 deletions cmake/toolchains/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,3 @@ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO ON CACHE STRING "")
if(WIN32)
add_definitions(-D_WIN32_WINNT=0x0601 -D_CRT_SECURE_NO_WARNINGS)
endif()

# Project options.
set(BOOST_JSON_BUILD_BENCHMARKS ON CACHE STRING "")

# Detect Boost tree.
if(NOT DEFINED BOOST_JSON_IN_BOOST_TREE AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../../../Jamroot")
set(BOOST_JSON_IN_BOOST_TREE ON CACHE STRING "")
endif()
61 changes: 37 additions & 24 deletions include/boost/http_proto/detail/header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
#include <boost/http_proto/method.hpp>
#include <boost/http_proto/status.hpp>
#include <boost/http_proto/version.hpp>
#include <boost/core/detail/string_view.hpp>

#include <boost/assert.hpp>
#include <boost/core/detail/string_view.hpp>

#include <cstdint>
#include <type_traits>

namespace boost {
namespace http_proto {
Expand All @@ -45,22 +46,26 @@ struct empty

struct header
{
// +------------+-----------+--------------+------------------------------+
// | start-line | headers | free space | entry[count-1] ... entry[0] |
// +------------+-----------+--------------+------------------------------+
// ^ ^ ^ ^
// buf buf+prefix buf+size buf+cap
// +------------+---------+------+------------+-----------------------------+
// | start-line | headers | \r\n | free space | entry[count-1] ... entry[0] |
// +------------+---------+------+------------+-----------------------------+
// ^ ^ ^ ^
// buf buf+prefix buf+size buf+cap

#ifdef BOOST_HTTP_PROTO_TEST_LIMITS
using offset_type = std::uint8_t;
#else
using offset_type = std::uint32_t;
#endif

static
constexpr
static constexpr
std::size_t max_offset =
std::numeric_limits<offset_type>::max();
std::numeric_limits<
offset_type>::max();

static constexpr
field unknown_field =
static_cast<field>(0);

struct entry
{
Expand Down Expand Up @@ -122,8 +127,6 @@ struct header
char const* cbuf = nullptr;
char* buf = nullptr;
std::size_t cap = 0;
std::size_t max_cap =
std::numeric_limits<std::size_t>::max();

offset_type size = 0;
offset_type count = 0;
Expand Down Expand Up @@ -151,22 +154,30 @@ struct header

public:
// in fields_base.hpp
static header& get(fields_base& f) noexcept;
static header&
get(fields_base& f) noexcept;

BOOST_HTTP_PROTO_DECL static header const*
get_default(detail::kind k) noexcept;
BOOST_HTTP_PROTO_DECL
static header const*
get_default(detail::kind k) noexcept;

// called from parser
explicit header(empty) noexcept;

BOOST_HTTP_PROTO_DECL header(detail::kind) noexcept;
BOOST_HTTP_PROTO_DECL void swap(header&) noexcept;
BOOST_HTTP_PROTO_DECL bool keep_alive() const noexcept;
BOOST_HTTP_PROTO_DECL
header(detail::kind) noexcept;

BOOST_HTTP_PROTO_DECL
void swap(header&) noexcept;

BOOST_HTTP_PROTO_DECL
bool keep_alive() const noexcept;

static std::size_t bytes_needed(
std::size_t size, std::size_t count) noexcept;
static std::size_t table_space(
std::size_t count) noexcept;

std::size_t table_space() const noexcept;

table tab() const noexcept;
Expand All @@ -188,7 +199,7 @@ struct header
void on_insert_connection(core::string_view);
void on_insert_content_length(core::string_view);
void on_insert_expect(core::string_view);
void on_insert_transfer_encoding();
void on_insert_transfer_encoding(core::string_view);
void on_insert_content_encoding(core::string_view);
void on_insert_upgrade(core::string_view);
void on_erase_connection();
Expand All @@ -202,11 +213,13 @@ struct header

// parsing

static std::size_t count_crlf(
core::string_view s) noexcept;
BOOST_HTTP_PROTO_DECL void parse(
std::size_t, header_limits const&,
system::error_code&) noexcept;
static std::size_t
count_crlf(core::string_view s) noexcept;

void parse(
std::size_t,
header_limits const&,
system::error_code&) noexcept;
};

} // detail
Expand Down
8 changes: 4 additions & 4 deletions include/boost/http_proto/field.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//
// Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.com)
// 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 All @@ -12,6 +13,7 @@

#include <boost/http_proto/detail/config.hpp>
#include <boost/core/detail/string_view.hpp>
#include <boost/optional.hpp>
#include <cstdint>
#include <iosfwd>
#include <type_traits>
Expand All @@ -21,9 +23,7 @@ namespace http_proto {

enum class field : unsigned short
{
unknown = 0, // must be zero

a_im,
a_im = 1,
accept,
accept_additions,
accept_charset,
Expand Down Expand Up @@ -399,7 +399,7 @@ to_string(field f);
@ref field::unknown if there is no match.
*/
BOOST_HTTP_PROTO_DECL
field
boost::optional<field>
string_to_field(
core::string_view s) noexcept;

Expand Down
1 change: 1 addition & 0 deletions include/boost/http_proto/fields.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class fields final
swap(fields& other) noexcept
{
h_.swap(other.h_);
std::swap(max_cap_, other.max_cap_);
}

/** Swap two instances
Expand Down
Loading
Loading