Browse Source

fixed detection of mimetype on uppercase extensions

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@632 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.2
Jan Kneschke 17 years ago
parent
commit
0212534554
  1. 4
      NEWS
  2. 10
      src/stat_cache.c
  3. 25
      tests/core-request.t

4
NEWS

@ -3,6 +3,10 @@
NEWS
====
- 1.4.2 -
* fixed mimetype detection on uppercase extensions
- 1.4.1 - 2005-08-22
* added a complete Class 1 complient mod_webdav

10
src/stat_cache.c

@ -400,10 +400,14 @@ handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_
for (k = 0; k < con->conf.mimetypes->used; k++) {
data_string *ds = (data_string *)con->conf.mimetypes->data[k];
buffer *type = ds->key;
if (ds->key->used == 0) continue;
if (buffer_is_equal_right_len(name, ds->key, ds->key->used - 1)) {
if (type->used == 0) continue;
/* check if the right side is the same */
if (type->used > name->used) continue;
if (0 == strncasecmp(name->ptr + name->used - type->used, type->ptr, type->used - 1)) {
buffer_copy_string_buffer(sce->content_type, ds->value);
break;
}

25
tests/core-request.t

@ -8,7 +8,7 @@ BEGIN {
use strict;
use IO::Socket;
use Test::More tests => 28;
use Test::More tests => 31;
use LightyTest;
my $tf = LightyTest->new();
@ -237,5 +237,28 @@ EOF
$t->{RESPONSE} = ( { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 400 } );
ok($tf->handle_http($t) == 0, 'Host missing');
print "\nContent-Type\n";
$t->{REQUEST} = ( <<EOF
GET /image.jpg HTTP/1.0
EOF
);
$t->{RESPONSE} = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Type' => 'image/jpeg' } );
ok($tf->handle_http($t) == 0, 'Content-Type - image/jpeg');
$t->{REQUEST} = ( <<EOF
GET /image.JPG HTTP/1.0
EOF
);
$t->{RESPONSE} = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Type' => 'image/jpeg' } );
ok($tf->handle_http($t) == 0, 'Content-Type - image/jpeg');
$t->{REQUEST} = ( <<EOF
GET /a HTTP/1.0
EOF
);
$t->{RESPONSE} = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Type' => 'application/octet-stream' } );
ok($tf->handle_http($t) == 0, 'Content-Type - unknown');
ok($tf->stop_proc == 0, "Stopping lighttpd");

Loading…
Cancel
Save