mirror of
https://github.com/omar-polo/gmid.git
synced 2024-09-28 05:21:48 +02:00
add "lang" server option
This commit is contained in:
parent
17b09e3cb7
commit
05c23a54ea
@ -1,5 +1,7 @@
|
||||
2021-01-19 Omar Polo <op@omarpolo.com>
|
||||
|
||||
* parse.y (servopt): add "lang" server option
|
||||
|
||||
* Dockerfile: add a dockerfile
|
||||
|
||||
2021-01-18 Omar Polo <op@omarpolo.com>
|
||||
|
5
gmid.1
5
gmid.1
@ -168,6 +168,11 @@ Enable the execution of CGI scripts if
|
||||
is a prefix of the user request string.
|
||||
An empty path "" will effectively enable the execution of any file
|
||||
with the executable bit set inside the root directory.
|
||||
.It Ic lang Ar string
|
||||
Specify the language tag for the text/gemini content served.
|
||||
If not specified, no
|
||||
.Dq lang
|
||||
parameter will be added in the response.
|
||||
.El
|
||||
.Sh CGI
|
||||
When CGI scripts are enabled for a directory, a request for an
|
||||
|
1
gmid.h
1
gmid.h
@ -59,6 +59,7 @@ struct vhost {
|
||||
const char *key;
|
||||
const char *dir;
|
||||
const char *cgi;
|
||||
char *lang;
|
||||
int dirfd;
|
||||
};
|
||||
|
||||
|
1
lex.l
1
lex.l
@ -58,6 +58,7 @@ protocols return TPROTOCOLS;
|
||||
mime return TMIME;
|
||||
default return TDEFAULT;
|
||||
type return TTYPE;
|
||||
lang return TLANG;
|
||||
server return TSERVER;
|
||||
|
||||
cert return TCERT;
|
||||
|
6
parse.y
6
parse.y
@ -43,7 +43,7 @@ extern void yyerror(const char*);
|
||||
}
|
||||
|
||||
%token TDAEMON TIPV6 TPORT TPROTOCOLS TMIME TDEFAULT TTYPE TSERVER
|
||||
%token TCERT TKEY TROOT TCGI
|
||||
%token TCERT TKEY TROOT TCGI TLANG
|
||||
%token TERR
|
||||
|
||||
%token <str> TSTRING
|
||||
@ -99,5 +99,9 @@ servopt : TCERT TSTRING { host->cert = $2; }
|
||||
if (*host->cgi == '/')
|
||||
host->cgi++;
|
||||
}
|
||||
| TLANG TSTRING {
|
||||
free(host->lang);
|
||||
host->lang = $2;
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -14,11 +14,14 @@ server "example.com" {
|
||||
root "/var/gemini/example.com"
|
||||
}
|
||||
|
||||
# another example server, this time with CGI enabled for scripts in
|
||||
# /cgi-bin/
|
||||
server "it.example.com" {
|
||||
cert "/path/to/cert.pem"
|
||||
key "/path/to/key.pem"
|
||||
root "/var/gemini/example.com"
|
||||
|
||||
# enable CGI scripts in /cgi-bin/
|
||||
cgi "/cgi-bin/"
|
||||
|
||||
# optional
|
||||
lang "it"
|
||||
}
|
||||
|
9
server.c
9
server.c
@ -256,7 +256,14 @@ start_reply(struct pollfd *pfd, struct client *client, int code, const char *rea
|
||||
client->meta = reason;
|
||||
client->state = S_INITIALIZING;
|
||||
|
||||
len = snprintf(buf, sizeof(buf), "%d %s\r\n", code, reason);
|
||||
snprintf(buf, sizeof(buf), "%d ", code);
|
||||
strlcat(buf, reason, sizeof(buf));
|
||||
if (!strcmp(reason, "text/gemini") && client->host->lang != NULL) {
|
||||
strlcat(buf, "; lang=", sizeof(buf));
|
||||
strlcat(buf, client->host->lang, sizeof(buf));
|
||||
}
|
||||
|
||||
len = strlcat(buf, "\r\n", sizeof(buf));
|
||||
assert(len < (int)sizeof(buf));
|
||||
|
||||
switch (tls_write(client->ctx, buf, len)) {
|
||||
|
Loading…
Reference in New Issue
Block a user