added SERVER_ADDR, REMOTE_PORT to mod_fastcgi and mod_cgi and

REQUEST_URI to mod_cgi


git-svn-id: svn://svn.lighttpd.net/lighttpd/trunk@32 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/release-1.3.11
Jan Kneschke 19 years ago
parent 6f6879d4a3
commit a39b52810e

@ -36,9 +36,6 @@ Feature Requests:
- ignore blank lines between requests
- handle \r\n at start of request
- cgi exec via shell
- added REMOTE_PORT, SERVER_ADDR to cgi/fastcgi
- REQUEST_URI to cgi
- don't set physical-file on 416-errors
- crash in read-post
- same config option twice -> aaa, aaa
- remove default port from Host:

@ -770,12 +770,26 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
#endif
);
cgi_env_add(&env, CONST_STR_LEN("SERVER_PORT"), buf);
cgi_env_add(&env, CONST_STR_LEN("SERVER_ADDR"),
#ifdef HAVE_IPV6
inet_ntop(srv_sock->addr.plain.sa_family,
srv_sock->addr.plain.sa_family == AF_INET6 ?
(const void *) &(srv_sock->addr.ipv6.sin6_addr) :
(const void *) &(srv_sock->addr.ipv4.sin_addr),
b2, sizeof(b2)-1)
#else
inet_ntoa(srv_sock->addr.ipv4.sin_addr)
#endif
);
cgi_env_add(&env, CONST_STR_LEN("REQUEST_METHOD"), get_http_method_name(con->request.http_method));
if (con->request.pathinfo->used) {
cgi_env_add(&env, CONST_STR_LEN("PATH_INFO"), con->request.pathinfo->ptr);
}
cgi_env_add(&env, CONST_STR_LEN("REDIRECT_STATUS"), "200");
cgi_env_add(&env, CONST_STR_LEN("QUERY_STRING"), con->uri.query->used ? con->uri.query->ptr : "");
cgi_env_add(&env, CONST_STR_LEN("REQUEST_URI"), con->request.orig_uri->used ? con->request.orig_uri->ptr : "");
cgi_env_add(&env, CONST_STR_LEN("REMOTE_ADDR"),
@ -789,6 +803,15 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
inet_ntoa(con->dst_addr.ipv4.sin_addr)
#endif
);
ltostr(buf,
#ifdef HAVE_IPV6
ntohs(con->dst_addr.plain.sa_family == AF_INET6 ? con->dst_addr.ipv6.sin6_port : con->dst_addr.ipv4.sin_port)
#else
ntohs(con->dst_addr.ipv4.sin_port)
#endif
);
cgi_env_add(&env, CONST_STR_LEN("REMOTE_PORT"), buf);
if (con->authed_user->used) {
cgi_env_add(&env, CONST_STR_LEN("REMOTE_USER"),

@ -1544,6 +1544,9 @@ static int fcgi_create_env(server *srv, handler_ctx *hctx, size_t request_id) {
connection *con = hctx->remote_conn;
server_socket *srv_sock = con->srv_socket;
sock_addr our_addr;
socklen_t our_addr_len;
/* send FCGI_BEGIN_REQUEST */
fcgi_header(&(beginRecord.header), FCGI_BEGIN_REQUEST, request_id, sizeof(beginRecord.body), 0);
@ -1587,6 +1590,26 @@ static int fcgi_create_env(server *srv, handler_ctx *hctx, size_t request_id) {
fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SERVER_PORT"), buf, strlen(buf));
/* get the server-side of the connection to the client */
our_addr_len = sizeof(our_addr);
if (-1 == getsockname(con->fd, &(our_addr.plain), &our_addr_len)) {
s = inet_ntop_cache_get_ip(srv, &(srv_sock->addr));
} else {
s = inet_ntop_cache_get_ip(srv, &(our_addr));
}
fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SERVER_ADDR"), s, strlen(s));
ltostr(buf,
#ifdef HAVE_IPV6
ntohs(con->dst_addr.plain.sa_family ? con->dst_addr.ipv6.sin6_port : con->dst_addr.ipv4.sin_port)
#else
ntohs(con->dst_addr.ipv4.sin_port)
#endif
);
fcgi_env_add(p->fcgi_env, CONST_STR_LEN("REMOTE_PORT"), buf, strlen(buf));
s = inet_ntop_cache_get_ip(srv, &(con->dst_addr));
fcgi_env_add(p->fcgi_env, CONST_STR_LEN("REMOTE_ADDR"), s, strlen(s));

Loading…
Cancel
Save