summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2014-08-25 14:27:54 +0000
committerreyk <reyk@openbsd.org>2014-08-25 14:27:54 +0000
commitbb431cfa29383abcdec5914a5ca99100fce42918 (patch)
treec11b2e7df98b35c75900b4782e5e76c00e077efb
parentWe have never limited the definition of "supported SPF modules" (diff)
downloadwireguard-openbsd-bb431cfa29383abcdec5914a5ca99100fce42918.tar.xz
wireguard-openbsd-bb431cfa29383abcdec5914a5ca99100fce42918.zip
Add a generic system-wide /usr/share/misc/mime.types file that can be
included in httpd.conf. httpd(8) now supports both mime.types flavours with or without semicolon at the end of the line (nginx- or apache-style). Discussed with many, with input from halex@ OK halex@
-rw-r--r--etc/examples/httpd.conf7
-rw-r--r--share/misc/mime.types100
-rw-r--r--usr.sbin/httpd/httpd.conf.528
-rw-r--r--usr.sbin/httpd/parse.y25
4 files changed, 143 insertions, 17 deletions
diff --git a/etc/examples/httpd.conf b/etc/examples/httpd.conf
index f8364fd37b9..71496a4fae0 100644
--- a/etc/examples/httpd.conf
+++ b/etc/examples/httpd.conf
@@ -1,4 +1,4 @@
-# $OpenBSD: httpd.conf,v 1.10 2014/08/06 20:29:54 reyk Exp $
+# $OpenBSD: httpd.conf,v 1.11 2014/08/25 14:27:54 reyk Exp $
#
# Macros
@@ -70,3 +70,8 @@ server "ipv6.example.com" {
listen on 2001:db8::53f6:3eab port 81
root "/htdocs/ipv6.example.com"
}
+
+# Include MIME types instead of the built-in ones
+types {
+ include "/usr/share/misc/mime.types"
+}
diff --git a/share/misc/mime.types b/share/misc/mime.types
new file mode 100644
index 00000000000..31e1f4f41c7
--- /dev/null
+++ b/share/misc/mime.types
@@ -0,0 +1,100 @@
+# $OpenBSD: mime.types,v 1.1 2014/08/25 14:27:54 reyk Exp $
+
+application/atom+xml atom
+application/font-woff woff
+application/java-archive jar war ear
+application/javascript js
+application/json json
+application/mac-binhex40 hqx
+application/msword doc
+application/octet-stream bin exe dll
+application/octet-stream deb
+application/octet-stream dmg
+application/octet-stream iso img
+application/octet-stream msi msp msm
+application/pdf pdf
+application/postscript ps eps ai
+application/rss+xml rss
+application/rtf rtf
+application/vnd.apple.mpegurl m3u8
+application/vnd.google-earth.kml+xml kml
+application/vnd.google-earth.kmz kmz
+application/vnd.ms-excel xls
+application/vnd.ms-fontobject eot
+application/vnd.ms-powerpoint ppt
+application/vnd.oasis.opendocument.chart odc
+application/vnd.oasis.opendocument.chart-template otc
+application/vnd.oasis.opendocument.database odb
+application/vnd.oasis.opendocument.formula odf
+application/vnd.oasis.opendocument.formula-template otf
+application/vnd.oasis.opendocument.graphics odg
+application/vnd.oasis.opendocument.graphics-template otg
+application/vnd.oasis.opendocument.image odi
+application/vnd.oasis.opendocument.image-template oti
+application/vnd.oasis.opendocument.presentation odp
+application/vnd.oasis.opendocument.presentation-template otp
+application/vnd.oasis.opendocument.spreadsheet ods
+application/vnd.oasis.opendocument.spreadsheet-template ots
+application/vnd.oasis.opendocument.text odt
+application/vnd.oasis.opendocument.text-master odm
+application/vnd.oasis.opendocument.text-template ott
+application/vnd.oasis.opendocument.text-web oth
+application/vnd.wap.wmlc wmlc
+application/x-7z-compressed 7z
+application/x-cocoa cco
+application/x-java-archive-diff jardiff
+application/x-java-jnlp-file jnlp
+application/x-makeself run
+application/x-ns-proxy-autoconfig pac
+application/x-perl pl pm
+application/x-pilot prc pdb
+application/x-rar-compressed rar
+application/x-redhat-package-manager rpm
+application/x-sea sea
+application/x-shockwave-flash swf
+application/x-stuffit sit
+application/x-tcl tcl tk
+application/x-x509-ca-cert der pem crt
+application/x-xpinstall xpi
+application/xhtml+xml xhtml
+application/zip zip
+
+audio/basic au snd
+audio/midi mid midi kar
+audio/mpeg mp3
+audio/ogg ogg
+audio/x-m4a m4a
+audio/x-realaudio ra
+
+image/gif gif
+image/jpeg jpeg jpg
+image/png png
+image/svg+xml svg svgz
+image/tiff tif tiff
+image/vnd.wap.wbmp wbmp
+image/webp webp
+image/x-icon ico
+image/x-jng jng
+image/x-ms-bmp mp
+
+text/css css
+text/html html htm shtml
+text/mathml mml
+text/plain txt
+text/vnd.sun.j2me.app-descriptor jad
+text/vnd.wap.wml wml
+text/x-component htc
+text/xml xml
+
+video/3gpp 3gpp 3gp
+video/mp2t ts
+video/mp4 mp4
+video/mpeg mpeg mpg
+video/quicktime mov
+video/webm webm
+video/x-flv flv
+video/x-m4v m4v
+video/x-mng mng
+video/x-ms-asf asx asf
+video/x-ms-wmv wmv
+video/x-msvideo avi
diff --git a/usr.sbin/httpd/httpd.conf.5 b/usr.sbin/httpd/httpd.conf.5
index 8a539f2de91..788d0a95487 100644
--- a/usr.sbin/httpd/httpd.conf.5
+++ b/usr.sbin/httpd/httpd.conf.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: httpd.conf.5,v 1.32 2014/08/17 18:46:29 jmc Exp $
+.\" $OpenBSD: httpd.conf.5,v 1.33 2014/08/25 14:27:54 reyk Exp $
.\"
.\" Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: August 17 2014 $
+.Dd $Mdocdate: August 25 2014 $
.Dt HTTPD.CONF 5
.Os
.Sh NAME
@@ -324,7 +324,7 @@ The
.Ic types
section must include one or more lines of the following syntax:
.Bl -tag -width Ds
-.It Ar type/subtype Ar name Op Ar name ... ;
+.It Ar type/subtype Ar name Op Ar name ...
Set the media
.Ar type
and
@@ -332,6 +332,10 @@ and
to the specified extension
.Ar name .
One or more names can be specified per line.
+Each line may end with an optional semicolon.
+.It Ic include Ar file
+Include types definitions from an external file, for example
+.Pa /usr/share/misc/mime.types .
.El
.Sh EXAMPLES
The following example will start one server that is pre-forked two
@@ -348,14 +352,14 @@ server "default" {
}
types {
- text/css css;
- text/html htm html;
- text/txt txt;
- image/gif gif;
- image/jpeg jpg jpeg;
- image/png png;
- application/javascript js;
- application/xml xml;
+ text/css css
+ text/html htm html
+ text/txt txt
+ image/gif gif
+ image/jpeg jpg jpeg
+ image/png png
+ application/javascript js
+ application/xml xml
}
.Ed
.Pp
@@ -381,7 +385,7 @@ server "intranet.example.com" {
}
.Ed
.Pp
-The syntax of the types section is compatible with the format used by
+The syntax of the types section is also compatible with the format used by
.Xr nginx 8 ,
so it is possible to include its
.Pa mime.types
diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y
index d66f2077874..44cf90c68c9 100644
--- a/usr.sbin/httpd/parse.y
+++ b/usr.sbin/httpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.35 2014/08/09 07:35:45 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.36 2014/08/25 14:27:54 reyk Exp $ */
/*
* Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -135,6 +135,7 @@ typedef struct {
%type <v.port> port
%type <v.number> optssl
%type <v.tv> timeout
+%type <v.string> numberstring
%%
@@ -660,7 +661,7 @@ types : TYPES '{' optnl mediaopts_l '}'
;
mediaopts_l : mediaopts_l mediaoptsl nl
- | mediaoptsl optnl
+ | mediaoptsl nl
;
mediaoptsl : STRING '/' STRING {
@@ -677,14 +678,15 @@ mediaoptsl : STRING '/' STRING {
}
free($1);
free($3);
- } medianames_l ';'
+ } medianames_l optsemicolon
+ | include
;
medianames_l : medianames_l medianamesl
| medianamesl
;
-medianamesl : STRING {
+medianamesl : numberstring {
if (strlcpy(media.media_name, $1,
sizeof(media.media_name)) >=
sizeof(media.media_name)) {
@@ -751,11 +753,26 @@ timeout : NUMBER
}
;
+numberstring : NUMBER {
+ char *s;
+ if (asprintf(&s, "%lld", $1) == -1) {
+ yyerror("asprintf: number");
+ YYERROR;
+ }
+ $$ = s;
+ }
+ | STRING
+ ;
+
comma : ','
| nl
| /* empty */
;
+optsemicolon : ';'
+ |
+ ;
+
optnl : '\n' optnl
|
;