nghttpx: Delete replaced header fields

This commit is contained in:
Tatsuhiro Tsujikawa 2015-09-05 01:18:18 +09:00
parent 226a09b04a
commit 21e1af2ae7
2 changed files with 18 additions and 6 deletions

View File

@ -208,13 +208,19 @@ mrb_value request_mod_header(mrb_state *mrb, mrb_value self, bool repl) {
key = mrb_funcall(mrb, key, "downcase", 0);
if (repl) {
// making name empty will effectively delete header fields
for (auto &hd : downstream->get_request_headers()) {
size_t p = 0;
auto &headers = downstream->get_request_headers();
for (size_t i = 0; i < headers.size(); ++i) {
auto &hd = headers[i];
if (util::streq(std::begin(hd.name), hd.name.size(), RSTRING_PTR(key),
RSTRING_LEN(key))) {
hd.name = "";
continue;
}
if (i != p) {
headers[p++] = std::move(hd);
}
}
headers.resize(p);
}
if (mrb_obj_is_instance_of(mrb, values, mrb->array_class)) {

View File

@ -112,13 +112,19 @@ mrb_value response_mod_header(mrb_state *mrb, mrb_value self, bool repl) {
key = mrb_funcall(mrb, key, "downcase", 0);
if (repl) {
// making name empty will effectively delete header fields
for (auto &hd : downstream->get_response_headers()) {
size_t p = 0;
auto &headers = downstream->get_response_headers();
for (size_t i = 0; i < headers.size(); ++i) {
auto &hd = headers[i];
if (util::streq(std::begin(hd.name), hd.name.size(), RSTRING_PTR(key),
RSTRING_LEN(key))) {
hd.name = "";
continue;
}
if (i != p) {
headers[p++] = std::move(hd);
}
}
headers.resize(p);
}
if (mrb_obj_is_instance_of(mrb, values, mrb->array_class)) {