mirror of https://github.com/omar-polo/gmid.git
rename `mime MIME EXT' to `map MIME to-ext EXT'
With the newish automatic string concatenation, options like `mime' that accepts two strings as parameter start to become ambiguous: which strings gets concatenated? Instead of trying to document in the manpage which argument(s) is subject to string concatenation, do the concat always and introduce a separator. In the case of mime, `to-ext' now acts as a separator to distinguish. While there, also use a new keyword because it sounds better. It's dead-easy to upgrade to the new configuration, possibly with some sed magic, but for the moment the old `mime' form is preserved: (with a warning!) Will be dropped in the next release.
This commit is contained in:
parent
d93c819182
commit
d19951cf03
|
@ -1,3 +1,7 @@
|
||||||
|
2021-07-08 Omar Polo <op@omarpolo.com>
|
||||||
|
|
||||||
|
* parse.y (option): rename `mime MIME EXT' to `map MIME to-ext EXT', but retain the old `mime' for compatibility.
|
||||||
|
|
||||||
2021-07-06 Omar Polo <op@omarpolo.com>
|
2021-07-06 Omar Polo <op@omarpolo.com>
|
||||||
|
|
||||||
* regress/gg.c (main): add -T timeout
|
* regress/gg.c (main): add -T timeout
|
||||||
|
|
8
gmid.1
8
gmid.1
|
@ -196,8 +196,8 @@ may enforce this.
|
||||||
.It Ic ipv6 Ar bool
|
.It Ic ipv6 Ar bool
|
||||||
Enable or disable IPv6 support.
|
Enable or disable IPv6 support.
|
||||||
By default is off.
|
By default is off.
|
||||||
.It Ic mime Ar mime-type Ar file-extension
|
.It Ic map Ar mime-type Cm to-ext Ar file-extension
|
||||||
Add a mapping for the given
|
Add a mapping for
|
||||||
.Ar file-extension
|
.Ar file-extension
|
||||||
to the given
|
to the given
|
||||||
.Ar mime-type .
|
.Ar mime-type .
|
||||||
|
@ -524,7 +524,7 @@ To auto-detect the MIME type of the response
|
||||||
looks at the file extension and consults its internal table.
|
looks at the file extension and consults its internal table.
|
||||||
By default the following mappings are loaded, but they can be
|
By default the following mappings are loaded, but they can be
|
||||||
overridden or extended using the
|
overridden or extended using the
|
||||||
.Ic mime
|
.Ic map
|
||||||
configuration option.
|
configuration option.
|
||||||
If no MIME is found, the value of
|
If no MIME is found, the value of
|
||||||
.Ic default type
|
.Ic default type
|
||||||
|
@ -590,7 +590,7 @@ ipv6 on # enable ipv6
|
||||||
|
|
||||||
protocols "tlsv1.3"
|
protocols "tlsv1.3"
|
||||||
|
|
||||||
mime "application/rtf" "rtf"
|
map "application/rtf" to-ext "rtf"
|
||||||
|
|
||||||
server "example.com" {
|
server "example.com" {
|
||||||
cert "/path/to/cert.pem"
|
cert "/path/to/cert.pem"
|
||||||
|
|
13
parse.y
13
parse.y
|
@ -88,7 +88,7 @@ char *symget(const char *);
|
||||||
%token TIPV6 TPORT TPROTOCOLS TMIME TDEFAULT TTYPE TCHROOT TUSER TSERVER
|
%token TIPV6 TPORT TPROTOCOLS TMIME TDEFAULT TTYPE TCHROOT TUSER TSERVER
|
||||||
%token TPREFORK TLOCATION TCERT TKEY TROOT TCGI TENV TLANG TLOG TINDEX TAUTO
|
%token TPREFORK TLOCATION TCERT TKEY TROOT TCGI TENV TLANG TLOG TINDEX TAUTO
|
||||||
%token TSTRIP TBLOCK TRETURN TENTRYPOINT TREQUIRE TCLIENT TCA TALIAS TTCP
|
%token TSTRIP TBLOCK TRETURN TENTRYPOINT TREQUIRE TCLIENT TCA TALIAS TTCP
|
||||||
%token TFASTCGI TSPAWN TPARAM
|
%token TFASTCGI TSPAWN TPARAM TMAP TTOEXT
|
||||||
|
|
||||||
%token TERR
|
%token TERR
|
||||||
|
|
||||||
|
@ -138,7 +138,14 @@ var : TSTRING '=' string {
|
||||||
|
|
||||||
option : TCHROOT string { conf.chroot = $2; }
|
option : TCHROOT string { conf.chroot = $2; }
|
||||||
| TIPV6 TBOOL { conf.ipv6 = $2; }
|
| TIPV6 TBOOL { conf.ipv6 = $2; }
|
||||||
| TMIME TSTRING string { add_mime(&conf.mime, $2, $3); }
|
| TMIME TSTRING string {
|
||||||
|
fprintf(stderr, "%s:%d: `mime MIME EXT' is deprecated and "
|
||||||
|
"will be removed in a future version, "
|
||||||
|
"please use the new syntax: `map MIME to-ext EXT'",
|
||||||
|
config_path, yylval.lineno+1);
|
||||||
|
add_mime(&conf.mime, $2, $3);
|
||||||
|
}
|
||||||
|
| TMAP string TTOEXT string { add_mime(&conf.mime, $3, $5); }
|
||||||
| TPORT TNUM { conf.port = $2; }
|
| TPORT TNUM { conf.port = $2; }
|
||||||
| TPREFORK TNUM { conf.prefork = check_prefork_num($2); }
|
| TPREFORK TNUM { conf.prefork = check_prefork_num($2); }
|
||||||
| TPROTOCOLS string {
|
| TPROTOCOLS string {
|
||||||
|
@ -360,6 +367,7 @@ static struct keyword {
|
||||||
{"lang", TLANG},
|
{"lang", TLANG},
|
||||||
{"location", TLOCATION},
|
{"location", TLOCATION},
|
||||||
{"log", TLOG},
|
{"log", TLOG},
|
||||||
|
{"map", TMAP},
|
||||||
{"mime", TMIME},
|
{"mime", TMIME},
|
||||||
{"param", TPARAM},
|
{"param", TPARAM},
|
||||||
{"port", TPORT},
|
{"port", TPORT},
|
||||||
|
@ -372,6 +380,7 @@ static struct keyword {
|
||||||
{"spawn", TSPAWN},
|
{"spawn", TSPAWN},
|
||||||
{"strip", TSTRIP},
|
{"strip", TSTRIP},
|
||||||
{"tcp", TTCP},
|
{"tcp", TTCP},
|
||||||
|
{"to-ext", TTOEXT},
|
||||||
{"type", TTYPE},
|
{"type", TTYPE},
|
||||||
{"user", TUSER},
|
{"user", TUSER},
|
||||||
};
|
};
|
||||||
|
|
|
@ -148,7 +148,7 @@ echo OK GET /hello
|
||||||
check "should be running"
|
check "should be running"
|
||||||
|
|
||||||
# try with custom mime
|
# try with custom mime
|
||||||
config 'mime "text/x-funny-text" "gmi"' 'default type "application/x-trash"'
|
config 'map "text/x-funny-text" to-ext "gmi"' 'default type "application/x-trash"'
|
||||||
checkconf
|
checkconf
|
||||||
restart
|
restart
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue