From a1843e5f6cac5bb9999b69b7140a969c839ddce9 Mon Sep 17 00:00:00 2001 From: Bob Tennent Date: Mon, 7 Apr 2014 11:27:04 -0400 Subject: [PATCH] Correct headers for .svgz content X-sthttpd-Bug: 3 X-sthttpd-Bug-URL: http://opensource.dyc.edu/bugzilla3/show_bug.cgi?id=3 Signed-off-by: Anthony G. Basile --- src/libhttpd.c | 58 ++++++++++++++++++------------------------ src/mime_encodings.h | 1 + src/mime_encodings.txt | 1 + 3 files changed, 27 insertions(+), 33 deletions(-) diff --git a/src/libhttpd.c b/src/libhttpd.c index 6c02ac1..375bd55 100644 --- a/src/libhttpd.c +++ b/src/libhttpd.c @@ -2554,16 +2554,14 @@ figure_mime( httpd_conn* hc ) /* Peel off encoding extensions until there aren't any more. */ n_me_indexes = 0; + hc->type = default_type; for ( prev_dot = &hc->expnfilename[strlen(hc->expnfilename)]; ; prev_dot = dot ) { for ( dot = prev_dot - 1; dot >= hc->expnfilename && *dot != '.'; --dot ) ; if ( dot < hc->expnfilename ) { - /* No dot found. No more encoding extensions, and no type - ** extension either. - */ - hc->type = default_type; + /* No dot found. No more extensions. */ goto done; } ext = dot + 1; @@ -2580,39 +2578,33 @@ figure_mime( httpd_conn* hc ) me_indexes[n_me_indexes] = i; ++n_me_indexes; } - goto next; + break; } } - /* No encoding extension found. Break and look for a type extension. */ - break; - - next: ; + /* Binary search for a matching type extension. */ + top = n_typ_tab - 1; + bot = 0; + while ( top >= bot ) + { + mid = ( top + bot ) / 2; + r = strncasecmp( ext, typ_tab[mid].ext, ext_len ); + if ( r < 0 ) + top = mid - 1; + else if ( r > 0 ) + bot = mid + 1; + else + if ( ext_len < typ_tab[mid].ext_len ) + top = mid - 1; + else if ( ext_len > typ_tab[mid].ext_len ) + bot = mid + 1; + else + { + hc->type = typ_tab[mid].val; + goto done; + } + } } - /* Binary search for a matching type extension. */ - top = n_typ_tab - 1; - bot = 0; - while ( top >= bot ) - { - mid = ( top + bot ) / 2; - r = strncasecmp( ext, typ_tab[mid].ext, ext_len ); - if ( r < 0 ) - top = mid - 1; - else if ( r > 0 ) - bot = mid + 1; - else - if ( ext_len < typ_tab[mid].ext_len ) - top = mid - 1; - else if ( ext_len > typ_tab[mid].ext_len ) - bot = mid + 1; - else - { - hc->type = typ_tab[mid].val; - goto done; - } - } - hc->type = default_type; - done: /* The last thing we do is actually generate the mime-encoding header. */ diff --git a/src/mime_encodings.h b/src/mime_encodings.h index f12bd7f..82e389c 100644 --- a/src/mime_encodings.h +++ b/src/mime_encodings.h @@ -1,3 +1,4 @@ { "Z", 0, "compress", 0 }, { "gz", 0, "gzip", 0 }, +{ "svgz", 0, "gzip", 0 }, { "uu", 0, "x-uuencode", 0 }, diff --git a/src/mime_encodings.txt b/src/mime_encodings.txt index 2d3952d..116376c 100644 --- a/src/mime_encodings.txt +++ b/src/mime_encodings.txt @@ -5,4 +5,5 @@ Z compress gz gzip +svgz gzip uu x-uuencode -- 2.45.2