Browse Source

append X-Forwarded-For to existing headers

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@743 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.6
Jan Kneschke 16 years ago
parent
commit
8bf86d6d8d
  1. 15
      src/mod_proxy.c

15
src/mod_proxy.c

@ -402,7 +402,7 @@ static int proxy_create_env(server *srv, handler_ctx *hctx) {
connection *con = hctx->remote_conn;
buffer *b;
UNUSED(srv);
data_string *ds_dst;
/* build header */
@ -414,6 +414,15 @@ static int proxy_create_env(server *srv, handler_ctx *hctx) {
buffer_append_string_buffer(b, con->request.uri);
BUFFER_APPEND_STRING_CONST(b, " HTTP/1.0\r\n");
if (NULL == (ds_dst = (data_string *)array_get_unused_element(con->request.headers, TYPE_STRING))) {
ds_dst = data_string_init();
}
BUFFER_COPY_STRING_CONST(ds_dst->key, "X-Forwarded-For");
buffer_append_string(ds_dst->value, inet_ntop_cache_get_ip(srv, &(con->dst_addr)));
array_insert_unique(con->request.headers, (data_unset *)ds_dst);
/* request header */
for (i = 0; i < con->request.headers->used; i++) {
@ -431,10 +440,6 @@ static int proxy_create_env(server *srv, handler_ctx *hctx) {
}
}
BUFFER_APPEND_STRING_CONST(b, "X-Forwarded-For: ");
buffer_append_string(b, inet_ntop_cache_get_ip(srv, &(con->dst_addr)));
BUFFER_APPEND_STRING_CONST(b, "\r\n");
BUFFER_APPEND_STRING_CONST(b, "\r\n");
hctx->wb->bytes_in += b->used - 1;

Loading…
Cancel
Save