diff options
author | stbuehler <stbuehler@152afb58-edef-0310-8abb-c4023f1b3aa9> | 2011-04-04 22:39:05 +0000 |
---|---|---|
committer | stbuehler <stbuehler@152afb58-edef-0310-8abb-c4023f1b3aa9> | 2011-04-04 22:39:05 +0000 |
commit | 22b8334a9adf62b4ea0ef85ffcd94410be7a3928 (patch) | |
tree | 83b8e6bc2f7f2c05b9088dd2f7cdef491f22d226 | |
parent | b8607cdfda354d7a568edb4c400f207959256579 (diff) | |
download | lighttpd-22b8334a9adf62b4ea0ef85ffcd94410be7a3928.tar.gz |
Read hostname from absolute https:// uris in the request line (patch by Adrian Schröter <adrian@suse.de>)
git-svn-id: svn://svn.lighttpd.net/lighttpd/trunk@2786 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/request.c | 11 | ||||
-rwxr-xr-x | tests/request.t | 17 |
3 files changed, 25 insertions, 4 deletions
@@ -167,6 +167,7 @@ NEWS * Fix conditional interpretation of core options * proxy-backend-http: fix chunked encoding parser * more strict check for server.stat-cache-engine + * Read hostname from absolute https:// uris in the request line (patch by Adrian Schröter <adrian@suse.de>) - 1.5.0-r19.. - * -F option added for spawn-fcgi diff --git a/src/request.c b/src/request.c index 26463f24..816b5368 100644 --- a/src/request.c +++ b/src/request.c @@ -306,19 +306,24 @@ int http_request_parse(server *srv, connection *con, http_req *req) { } else { /* GET http://www.example.org/foobar */ char *sl; + int l; - if (0 != strncmp(BUF_STR(req->uri_raw), "http://", 7)) { + if (0 == strncmp(BUF_STR(req->uri_raw), "https://", 8)) { + l = 8; + } else if (0 == strncmp(BUF_STR(req->uri_raw), "http://", 7)) { + l = 7; + } else { con->http_status = 400; return 0; } - if (NULL == (sl = strchr(BUF_STR(req->uri_raw) + 7, '/'))) { + if (NULL == (sl = strchr(BUF_STR(req->uri_raw) + l, '/'))) { con->http_status = 400; return 0; } buffer_copy_string(con->request.uri, sl); - buffer_copy_string_len(con->request.http_host, BUF_STR(req->uri_raw) + 7, sl - BUF_STR(req->uri_raw) - 7); + buffer_copy_string_len(con->request.http_host, BUF_STR(req->uri_raw) + l, sl - BUF_STR(req->uri_raw) - l); if (request_check_hostname(con->request.http_host)) { if (srv->srvconf.log_request_header_on_error) { diff --git a/tests/request.t b/tests/request.t index cbd49861..8a53ac52 100755 --- a/tests/request.t +++ b/tests/request.t @@ -8,7 +8,7 @@ BEGIN { use strict; use IO::Socket; -use Test::More tests => 41; +use Test::More tests => 43; use LightyTest; my $tf = LightyTest->new(); @@ -89,6 +89,21 @@ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '-HTTP ok($tf->handle_http($t) == 0, 'HEAD request, mimetype text/html, content-length'); $t->{REQUEST} = ( <<EOF +HEAD http://123.example.org/12345.html HTTP/1.1 +Connection: close +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, '-HTTP-Content' => '', 'Content-Type' => 'text/html', 'Content-Length' => '6'} ]; +ok($tf->handle_http($t) == 0, 'Hostname in first line, HTTP/1.1'); + +$t->{REQUEST} = ( <<EOF +HEAD https://123.example.org/12345.html HTTP/1.0 +EOF + ); +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '-HTTP-Content' => '', 'Content-Type' => 'text/html', 'Content-Length' => '6'} ]; +ok($tf->handle_http($t) == 0, 'Hostname in first line as https url'); + +$t->{REQUEST} = ( <<EOF HEAD /foobar?foobar HTTP/1.0 EOF ); |