I would find it quite useful to have boa ignore the
case of file extensions. for example I have a
img_0032.jpg - the /etc/mime.types (copied from apache)
says *.jpg is image/jpeg, but once I request
img_0032.JPG I get the dialog to download the file,
instead of the browser showing the file...
$ wget -S --spider http://gw/IMG_0029.JPG
...
1 HTTP/1.0 200 OK
2 Date: Tue, 13 Apr 2004 22:59:28 GMT
3 Server: Boa/0.94.14rc19
...
9 Content-Type: text/plain
200 OK
$ wget -S --spider http://gw/IMG_0029.jpg
...
1 HTTP/1.0 200 OK
2 Date: Tue, 13 Apr 2004 23:00:29 GMT
3 Server: Boa/0.94.14rc19
...
9 Content-Type: image/jpeg
200 OK
I don't want to modify the mime.types for all funny
variations of jpg (Jpg, jPG, jpG...) and for other
extensions likewise..
Logged In: YES
user_id=13009
fixed... I now wrote a patch -- works for me:
--- hash.c Tue Jul 30 05:59:26 2002
+++ mod_hash.c Wed May 5 12:46:41 2004
@@ -186,6 +186,7 @@
unsigned get_mime_hash_value(char *extension)
{
unsigned int hash = 0;
+ int i = 0; // iteration integer for extension conversion
if (extension == NULL || extension[0] == '\0') {
/* FIXME */
@@ -194,6 +195,14 @@
return 0;
}
+
+ // extension conversion: convert all lowercase chars to
lowercase
+ while(extension[i++]){
+ if (extension[i] >= 'A' && extension[i] <= 'Z'){
+ extension[i] += 32;
+ }
+ }
+
hash = boa_hash(extension);
hash %= MIME_HASHTABLE_SIZE;
@@ -211,6 +220,7 @@
{
char *extension;
hash_struct *current;
+ int i = 0; // iteration integer for extension conversion
unsigned int hash;
@@ -218,6 +228,13 @@
if (!extension || *extension++ == '\0')
return default_type;
+
+ // extension conversion: convert all lowercase chars to
lowercase
+ while(extension[i++]){
+ if (extension[i] >= 'A' && extension[i] <= 'Z'){
+ extension[i] += 32;
+ }
+ }
hash = get_mime_hash_value(extension);
current = mime_hashtable[hash];
Logged In: YES
user_id=13009
I'm sorry for that not-so-much tested crap patch.
I have now written a patch, that actually works for a long
time now.
I'm talking about Boa/0.94.14rc20 now. here it is:
--- hash.c 2004-06-10 04:04:50.000000000 +0200
+++ hash_mod.c 2004-06-25 12:00:02.000000000 +0200
@@ -408,9 +408,11 @@
char *get_mime_type(const char *filename)
{
char *extension;
+ char *lower_extension;
hash_struct *current;
unsigned int hash;
+ unsigned int pos = 0;
if (filename == NULL) {
log_error_time();
@@ -438,8 +440,24 @@
/* make sure we hash on the 'bar' not the '.bar' */
++extension;
- hash = get_mime_hash_value(extension);
- current = hash_find(mime_hashtable, extension, hash);
+ lower_extension = strdup(extension);
+ if (lower_extension == NULL){
+ lower_extension = extension;
+ } else {
+ while (*lower_extension != '\0'){
+ pos += 1;
+ if (*lower_extension >= 'A' && *lower_extension <=
'Z'){
+ *lower_extension += 32;
+ }
+ lower_extension++;
+ }
+ lower_extension -= pos;
+ }
+
+ /*fprintf(stderr, "extension %s --> %s\n", extension,
lower_extension);*/
+
+ hash = get_mime_hash_value(lower_extension);
+ current = hash_find(mime_hashtable, lower_extension, hash);
return (current ? current->value : default_type);
}