-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathconfig.cpp
More file actions
76 lines (57 loc) · 1.84 KB
/
config.cpp
File metadata and controls
76 lines (57 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// Copyright (c) 2026 Vinnie Falco (vinnie.falco@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/cppalliance/http
//
#include <boost/http/config.hpp>
#include <boost/http/detail/except.hpp>
#include <boost/http/detail/header.hpp>
#include <cstdint>
#include <memory>
namespace boost {
namespace http {
std::size_t
parser_config_impl::
max_overread() const noexcept
{
return headers.max_size + min_buffer;
}
std::shared_ptr<parser_config_impl const>
make_parser_config(parser_config cfg)
{
if(cfg.max_prepare < 1)
detail::throw_invalid_argument();
auto impl = std::make_shared<parser_config_impl>(std::move(cfg));
/*
| fb | cb0 | cb1 | T | f |
fb flat_dynamic_buffer headers.max_size
cb0 circular_buffer min_buffer
cb1 circular_buffer min_buffer
f table max_table_space
*/
std::size_t space_needed = 0;
space_needed += impl->headers.valid_space_needed();
// cb0_, cb1_
space_needed += impl->min_buffer + impl->min_buffer;
// round up to alignof(detail::header::entry)
auto const al = alignof(detail::header::entry);
space_needed = al * ((space_needed + al - 1) / al);
impl->space_needed = space_needed;
impl->max_codec = 0; // not currently used for parser
return impl;
}
std::shared_ptr<serializer_config_impl const>
make_serializer_config(serializer_config cfg)
{
auto impl = std::make_shared<serializer_config_impl>();
static_cast<serializer_config&>(*impl) = std::move(cfg);
std::size_t space_needed = 0;
space_needed += impl->payload_buffer;
impl->space_needed = space_needed;
return impl;
}
} // http
} // boost