Commit a0dd8918 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Don't mutate *_key_prev_ in add_header

parent baa9b1ca
...@@ -350,10 +350,8 @@ void Downstream::crumble_request_cookie(std::vector<nghttp2_nv> &nva) { ...@@ -350,10 +350,8 @@ void Downstream::crumble_request_cookie(std::vector<nghttp2_nv> &nva) {
} }
namespace { namespace {
void add_header(bool &key_prev, size_t &sum, HeaderRefs &headers, void add_header(size_t &sum, HeaderRefs &headers, const StringRef &name,
const StringRef &name, const StringRef &value, bool no_index, const StringRef &value, bool no_index, int32_t token) {
int32_t token) {
key_prev = true;
sum += name.size() + value.size(); sum += name.size() + value.size();
headers.emplace_back(name, value, no_index, token); headers.emplace_back(name, value, no_index, token);
} }
...@@ -446,14 +444,14 @@ const HeaderRefs::value_type *FieldStore::header(const StringRef &name) const { ...@@ -446,14 +444,14 @@ const HeaderRefs::value_type *FieldStore::header(const StringRef &name) const {
void FieldStore::add_header_token(const StringRef &name, const StringRef &value, void FieldStore::add_header_token(const StringRef &name, const StringRef &value,
bool no_index, int32_t token) { bool no_index, int32_t token) {
shrpx::add_header(header_key_prev_, buffer_size_, headers_, name, value, shrpx::add_header(buffer_size_, headers_, name, value, no_index, token);
no_index, token);
} }
void FieldStore::alloc_add_header_name(const StringRef &name) { void FieldStore::alloc_add_header_name(const StringRef &name) {
auto name_ref = alloc_header_name(balloc_, name); auto name_ref = alloc_header_name(balloc_, name);
auto token = http2::lookup_token(name_ref); auto token = http2::lookup_token(name_ref);
add_header_token(name_ref, StringRef{}, false, token); add_header_token(name_ref, StringRef{}, false, token);
header_key_prev_ = true;
} }
void FieldStore::append_last_header_key(const char *data, size_t len) { void FieldStore::append_last_header_key(const char *data, size_t len) {
...@@ -476,14 +474,14 @@ void FieldStore::add_trailer_token(const StringRef &name, ...@@ -476,14 +474,14 @@ void FieldStore::add_trailer_token(const StringRef &name,
int32_t token) { int32_t token) {
// Header size limit should be applied to all header and trailer // Header size limit should be applied to all header and trailer
// fields combined. // fields combined.
shrpx::add_header(trailer_key_prev_, buffer_size_, trailers_, name, value, shrpx::add_header(buffer_size_, trailers_, name, value, no_index, token);
no_index, token);
} }
void FieldStore::alloc_add_trailer_name(const StringRef &name) { void FieldStore::alloc_add_trailer_name(const StringRef &name) {
auto name_ref = alloc_header_name(balloc_, name); auto name_ref = alloc_header_name(balloc_, name);
auto token = http2::lookup_token(name_ref); auto token = http2::lookup_token(name_ref);
add_trailer_token(name_ref, StringRef{}, false, token); add_trailer_token(name_ref, StringRef{}, false, token);
trailer_key_prev_ = true;
} }
void FieldStore::append_last_trailer_key(const char *data, size_t len) { void FieldStore::append_last_trailer_key(const char *data, size_t len) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment