diff options
author | Omar Polo <op@omarpolo.com> | 2021-01-19 10:58:29 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2021-01-19 10:58:29 +0000 |
commit | 05c23a54ea7a2fdfb35d08cdaedea01ab3d5b427 (patch) | |
tree | e768add08b54fd1b780f608608f1aa15887abaac /server.c | |
parent | 17b09e3cb7158d3b817b42b3f1498b43dcc41e9f (diff) |
add "lang" server option
Diffstat (limited to 'server.c')
-rw-r--r-- | server.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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)) { |