nghttpx: Simplify xff handling
This commit is contained in:
parent
e4816c5ba9
commit
7be0217bc0
|
@ -366,15 +366,18 @@ int Http2DownstreamConnection::push_request_headers() {
|
|||
}
|
||||
|
||||
std::string xff_value;
|
||||
auto xff = req.fs.header(http2::HD_X_FORWARDED_FOR);
|
||||
auto xff = get_config()->strip_incoming_x_forwarded_for
|
||||
? nullptr
|
||||
: req.fs.header(http2::HD_X_FORWARDED_FOR);
|
||||
|
||||
if (get_config()->add_x_forwarded_for) {
|
||||
if (xff && !get_config()->strip_incoming_x_forwarded_for) {
|
||||
if (xff) {
|
||||
xff_value = (*xff).value;
|
||||
xff_value += ", ";
|
||||
}
|
||||
xff_value += upstream->get_client_handler()->get_ipaddr();
|
||||
nva.push_back(http2::make_nv_ls("x-forwarded-for", xff_value));
|
||||
} else if (xff && !get_config()->strip_incoming_x_forwarded_for) {
|
||||
} else if (xff) {
|
||||
nva.push_back(http2::make_nv_ls_nocopy("x-forwarded-for", (*xff).value));
|
||||
}
|
||||
|
||||
|
|
|
@ -331,16 +331,19 @@ int HttpDownstreamConnection::push_request_headers() {
|
|||
buf->append("\r\n");
|
||||
}
|
||||
|
||||
auto xff = req.fs.header(http2::HD_X_FORWARDED_FOR);
|
||||
auto xff = get_config()->strip_incoming_x_forwarded_for
|
||||
? nullptr
|
||||
: req.fs.header(http2::HD_X_FORWARDED_FOR);
|
||||
|
||||
if (get_config()->add_x_forwarded_for) {
|
||||
buf->append("X-Forwarded-For: ");
|
||||
if (xff && !get_config()->strip_incoming_x_forwarded_for) {
|
||||
if (xff) {
|
||||
buf->append((*xff).value);
|
||||
buf->append(", ");
|
||||
}
|
||||
buf->append(client_handler_->get_ipaddr());
|
||||
buf->append("\r\n");
|
||||
} else if (xff && !get_config()->strip_incoming_x_forwarded_for) {
|
||||
} else if (xff) {
|
||||
buf->append("X-Forwarded-For: ");
|
||||
buf->append((*xff).value);
|
||||
buf->append("\r\n");
|
||||
|
|
Loading…
Reference in New Issue