allow numbers in header-keys

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@523 152afb58-edef-0310-8abb-c4023f1b3aa9
This commit is contained in:
Jan Kneschke 2005-08-08 16:32:17 +00:00
parent 6b85d74c2b
commit cd4c324ff2
8 changed files with 61 additions and 19 deletions

View File

@ -158,8 +158,8 @@ int http_response_redirect_to_directory(server *srv, connection *con) {
case AF_INET:
if (NULL == (he = gethostbyaddr((char *)&our_addr.ipv4.sin_addr, sizeof(struct in_addr), AF_INET))) {
log_error_write(srv, __FILE__, __LINE__,
"SSSS", "NOTICE: gethostbyaddr failed: ",
hstrerror(h_errno), ", using ip-address instead");
"SdSS", "NOTICE: gethostbyaddr failed: ",
h_errno, ", using ip-address instead");
buffer_append_string(o, inet_ntoa(our_addr.ipv4.sin_addr));
} else {

View File

@ -862,9 +862,15 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
buffer_prepare_append(p->tmp_buf, ds->key->used + 2);
for (j = 0; j < ds->key->used - 1; j++) {
p->tmp_buf->ptr[p->tmp_buf->used++] =
isalpha((unsigned char)ds->key->ptr[j]) ?
toupper((unsigned char)ds->key->ptr[j]) : '_';
char cr = '_';
if (light_isalpha(ds->key->ptr[j])) {
/* upper-case */
cr = ds->key->ptr[j] & ~32;
} else if (light_isdigit(ds->key->ptr[j])) {
/* copy */
cr = ds->key->ptr[j];
}
p->tmp_buf->ptr[p->tmp_buf->used++] = cr;
}
p->tmp_buf->ptr[p->tmp_buf->used++] = '\0';

View File

@ -690,8 +690,8 @@ static int fcgi_spawn_connection(server *srv,
if (NULL == (he = gethostbyname(host->host->ptr))) {
log_error_write(srv, __FILE__, __LINE__,
"ssb", "gethostbyname failed: ",
hstrerror(h_errno), host->host);
"sdb", "gethostbyname failed: ",
h_errno, host->host);
return -1;
}
@ -1512,9 +1512,15 @@ static int fcgi_env_add_request_headers(server *srv, connection *con, plugin_dat
buffer_prepare_append(srv->tmp_buf, ds->key->used + 2);
for (j = 0; j < ds->key->used - 1; j++) {
srv->tmp_buf->ptr[srv->tmp_buf->used++] =
light_isalpha(ds->key->ptr[j]) ?
ds->key->ptr[j] & ~32 : '_';
char c = '_';
if (light_isalpha(ds->key->ptr[j])) {
/* upper-case */
c = ds->key->ptr[j] & ~32;
} else if (light_isdigit(ds->key->ptr[j])) {
/* copy */
c = ds->key->ptr[j];
}
srv->tmp_buf->ptr[srv->tmp_buf->used++] = c;
}
srv->tmp_buf->ptr[srv->tmp_buf->used++] = '\0';

View File

@ -670,8 +670,8 @@ static int scgi_spawn_connection(server *srv,
if (NULL == (he = gethostbyname(host->host->ptr))) {
log_error_write(srv, __FILE__, __LINE__,
"ssb", "gethostbyname failed: ",
hstrerror(h_errno), host->host);
"sdb", "gethostbyname failed: ",
h_errno, host->host);
return -1;
}

View File

@ -172,9 +172,15 @@ static int ssi_env_add_request_headers(server *srv, connection *con, plugin_data
buffer_prepare_append(srv->tmp_buf, ds->key->used + 2);
for (j = 0; j < ds->key->used - 1; j++) {
srv->tmp_buf->ptr[srv->tmp_buf->used++] =
isalpha((unsigned char)ds->key->ptr[j]) ?
toupper((unsigned char)ds->key->ptr[j]) : '_';
char c = '_';
if (light_isalpha(ds->key->ptr[j])) {
/* upper-case */
c = ds->key->ptr[j] & ~32;
} else if (light_isdigit(ds->key->ptr[j])) {
/* copy */
c = ds->key->ptr[j];
}
srv->tmp_buf->ptr[srv->tmp_buf->used++] = c;
}
srv->tmp_buf->ptr[srv->tmp_buf->used] = '\0';

View File

@ -202,8 +202,8 @@ int network_server_init(server *srv, buffer *host_token, specific_config *s) {
struct hostent *he;
if (NULL == (he = gethostbyname(host))) {
log_error_write(srv, __FILE__, __LINE__,
"sss", "gethostbyname failed: ",
hstrerror(h_errno), host);
"sds", "gethostbyname failed: ",
h_errno, host);
return -1;
}

View File

@ -1,4 +1,4 @@
EXTRA_DIST=cgi.php cgi.pl dummydir index.html index.txt phpinfo.php \
phpself.php redirect.php cgi-pathinfo.pl phphost.php pathinfo.php \
nph-status.pl prefix.fcgi
nph-status.pl prefix.fcgi get-header.pl
SUBDIRS=go indexfile expire

View File

@ -8,7 +8,7 @@ BEGIN {
use strict;
use IO::Socket;
use Test::More tests => 6;
use Test::More tests => 9;
use LightyTest;
my $tf = LightyTest->new();
@ -46,5 +46,29 @@ EOF
$t->{RESPONSE} = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } );
ok($tf->handle_http($t) == 0, 'NPH + perl, Bug #14');
$t->{REQUEST} = ( <<EOF
GET /get-header.pl?GATEWAY_INTERFACE HTTP/1.0
EOF
);
$t->{RESPONSE} = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'CGI/1.1' } );
ok($tf->handle_http($t) == 0, 'cgi-env: GATEWAY_INTERFACE');
$t->{REQUEST} = ( <<EOF
GET /get-header.pl?HTTP_XX_YY123 HTTP/1.0
xx-yy123: foo
EOF
);
$t->{RESPONSE} = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'foo' } );
ok($tf->handle_http($t) == 0, 'cgi-env: quoting headers with numbers');
$t->{REQUEST} = ( <<EOF
GET /get-header.pl?HTTP_HOST HTTP/1.0
Host: www.example.org
EOF
);
$t->{RESPONSE} = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'www.example.org' } );
ok($tf->handle_http($t) == 0, 'cgi-env: HTTP_HOST');
ok($tf->stop_proc == 0, "Stopping lighttpd");