~lastrosade/jsthttpd

a1843e5f6cac5bb9999b69b7140a969c839ddce9 — Bob Tennent 7 years ago 3254010
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 <blueness@gentoo.org>
3 files changed, 27 insertions(+), 33 deletions(-)

M src/libhttpd.c
M src/mime_encodings.h
M src/mime_encodings.txt
M src/libhttpd.c => src/libhttpd.c +25 -33
@@ 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. */

M src/mime_encodings.h => src/mime_encodings.h +1 -0
@@ 1,3 1,4 @@
{ "Z", 0, "compress", 0 },
{ "gz", 0, "gzip", 0 },
{ "svgz", 0, "gzip", 0 },
{ "uu", 0, "x-uuencode", 0 },

M src/mime_encodings.txt => src/mime_encodings.txt +1 -0
@@ 5,4 5,5 @@

Z	compress
gz	gzip
svgz	gzip
uu	x-uuencode