99//
1010
1111#include < boost/http_proto/detail/header.hpp>
12- #include < boost/http_proto/detail/align_up.hpp>
1312#include < boost/http_proto/field.hpp>
1413#include < boost/http_proto/fields_view_base.hpp>
1514#include < boost/http_proto/header_limits.hpp>
1615#include < boost/http_proto/rfc/list_rule.hpp>
1716#include < boost/http_proto/rfc/token_rule.hpp>
1817#include < boost/http_proto/rfc/upgrade_rule.hpp>
1918#include < boost/http_proto/rfc/detail/rules.hpp>
19+
20+ #include " ../rfc/transfer_encoding_rule.hpp"
21+
2022#include < boost/url/grammar/ci_string.hpp>
2123#include < boost/url/grammar/parse.hpp>
2224#include < boost/url/grammar/range_rule.hpp>
2527#include < boost/assert.hpp>
2628#include < boost/assert/source_location.hpp>
2729#include < boost/static_assert.hpp>
28- # include < string >
30+
2931#include < utility>
3032
31- #include " ../rfc/transfer_encoding_rule.hpp"
3233
3334namespace boost {
3435namespace http_proto {
@@ -212,11 +213,10 @@ bytes_needed(
212213 if (size < 19 )
213214 size = 19 ;
214215
215- return
216- align_up (
217- size,
218- alignof (header::entry)) +
219- count * sizeof (header::entry);
216+ // align size up to alignof(entry)
217+ size = (size + alignof (entry) - 1 ) & ~(alignof (entry) - 1 );
218+
219+ return size + count * sizeof (entry);
220220}
221221
222222std::size_t
@@ -1170,11 +1170,11 @@ parse_start_line(
11701170 auto sm = std::get<0 >(*rv);
11711171 h.req .method = string_to_method (sm);
11721172 h.req .method_len =
1173- static_cast <offset_type>(sm.size ());
1173+ static_cast <header:: offset_type>(sm.size ());
11741174 // target
11751175 auto st = std::get<1 >(*rv);
11761176 h.req .target_len =
1177- static_cast <offset_type>(st.size ());
1177+ static_cast <header:: offset_type>(st.size ());
11781178 // version
11791179 switch (std::get<2 >(*rv))
11801180 {
@@ -1231,7 +1231,7 @@ parse_start_line(
12311231 std::get<1 >(*rv).v );
12321232 h.res .status = std::get<1 >(*rv).st ;
12331233 }
1234- h.prefix = static_cast <offset_type>(it - it0);
1234+ h.prefix = static_cast <header:: offset_type>(it - it0);
12351235 h.size = h.prefix ;
12361236 h.on_start_line ();
12371237}
@@ -1259,7 +1259,7 @@ parse_field(
12591259 {
12601260 // final CRLF
12611261 h.size = static_cast <
1262- offset_type>(it - h.cbuf );
1262+ header:: offset_type>(it - h.cbuf );
12631263 return ;
12641264 }
12651265 if ( ec == grammar::error::need_more &&
@@ -1283,7 +1283,7 @@ parse_field(
12831283 remove_obs_fold (h.buf + h.size , it);
12841284 }
12851285 auto id = string_to_field (rv->name );
1286- h.size = static_cast <offset_type>(it - h.cbuf );
1286+ h.size = static_cast <header:: offset_type>(it - h.cbuf );
12871287
12881288 // add field table entry
12891289 if (h.buf != nullptr )
@@ -1292,13 +1292,13 @@ parse_field(
12921292 h.buf + h.cap )[h.count ];
12931293 auto const base =
12941294 h.buf + h.prefix ;
1295- e.np = static_cast <offset_type>(
1295+ e.np = static_cast <header:: offset_type>(
12961296 rv->name .data () - base);
1297- e.nn = static_cast <offset_type>(
1297+ e.nn = static_cast <header:: offset_type>(
12981298 rv->name .size ());
1299- e.vp = static_cast <offset_type>(
1299+ e.vp = static_cast <header:: offset_type>(
13001300 rv->value .data () - base);
1301- e.vn = static_cast <offset_type>(
1301+ e.vn = static_cast <header:: offset_type>(
13021302 rv->value .size ());
13031303 e.id = id;
13041304 }
0 commit comments