nghttpx: Delete replaced header fields
This commit is contained in:
parent
226a09b04a
commit
21e1af2ae7
|
@ -208,13 +208,19 @@ mrb_value request_mod_header(mrb_state *mrb, mrb_value self, bool repl) {
|
||||||
key = mrb_funcall(mrb, key, "downcase", 0);
|
key = mrb_funcall(mrb, key, "downcase", 0);
|
||||||
|
|
||||||
if (repl) {
|
if (repl) {
|
||||||
// making name empty will effectively delete header fields
|
size_t p = 0;
|
||||||
for (auto &hd : downstream->get_request_headers()) {
|
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),
|
if (util::streq(std::begin(hd.name), hd.name.size(), RSTRING_PTR(key),
|
||||||
RSTRING_LEN(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)) {
|
if (mrb_obj_is_instance_of(mrb, values, mrb->array_class)) {
|
||||||
|
|
|
@ -112,13 +112,19 @@ mrb_value response_mod_header(mrb_state *mrb, mrb_value self, bool repl) {
|
||||||
key = mrb_funcall(mrb, key, "downcase", 0);
|
key = mrb_funcall(mrb, key, "downcase", 0);
|
||||||
|
|
||||||
if (repl) {
|
if (repl) {
|
||||||
// making name empty will effectively delete header fields
|
size_t p = 0;
|
||||||
for (auto &hd : downstream->get_response_headers()) {
|
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),
|
if (util::streq(std::begin(hd.name), hd.name.size(), RSTRING_PTR(key),
|
||||||
RSTRING_LEN(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)) {
|
if (mrb_obj_is_instance_of(mrb, values, mrb->array_class)) {
|
||||||
|
|
Loading…
Reference in New Issue