aboutsummaryrefslogtreecommitdiff
path: root/server.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-01-19 10:58:29 +0000
committerOmar Polo <op@omarpolo.com>2021-01-19 10:58:29 +0000
commit05c23a54ea7a2fdfb35d08cdaedea01ab3d5b427 (patch)
treee768add08b54fd1b780f608608f1aa15887abaac /server.c
parent17b09e3cb7158d3b817b42b3f1498b43dcc41e9f (diff)
add "lang" server option
Diffstat (limited to 'server.c')
-rw-r--r--server.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/server.c b/server.c
index 0ce28d7..49d71f0 100644
--- a/server.c
+++ b/server.c
@@ -249,14 +249,21 @@ handle_open_conn(struct pollfd *fds, struct client *c)
int
start_reply(struct pollfd *pfd, struct client *client, int code, const char *reason)
{
- char buf[1030]; /* status + ' ' + max reply len + \r\n\0 */
+ char buf[1030]; /* status + ' ' + max reply len + \r\n\0 */
int len;
client->code = code;
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)) {