aboutsummaryrefslogtreecommitdiff
path: root/fcgi.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2022-11-27 15:35:10 +0000
committerOmar Polo <op@omarpolo.com>2022-11-27 15:35:10 +0000
commit97b306cbee6d105885a761e04274f661a0ec3757 (patch)
treee28086c92735e049e79d9613ecdec7da536d5f48 /fcgi.c
parent77718c121f89b39bd0095f10e2dbd2ff9df65281 (diff)
add an implicit fastcgi parameter: GEMINI_SEARCH_STRING
it’s the QUERY_STRING decoded if it’s a search-string (i.e. not a key-value pair.) It’s useful for scripts to avoid percent-decoding the querystring in the most common case of a query, because in Gemini querystrings key-value paired are not common. Idea from a discussion with Allen Sobot.
Diffstat (limited to 'fcgi.c')
-rw-r--r--fcgi.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fcgi.c b/fcgi.c
index 4c71d8f..2d1dc86 100644
--- a/fcgi.c
+++ b/fcgi.c
@@ -344,6 +344,7 @@ void
fcgi_req(struct client *c)
{
char addr[NI_MAXHOST], buf[22];
+ char *qs;
int e;
time_t tim;
struct tm tminfo;
@@ -368,6 +369,14 @@ fcgi_req(struct client *c)
fcgi_send_param(c->cgibev, "SERVER_PROTOCOL", "GEMINI");
fcgi_send_param(c->cgibev, "SERVER_SOFTWARE", GMID_VERSION);
+ if (*c->iri.query != '\0' &&
+ strchr(c->iri.query, '=') == NULL &&
+ (qs = strdup(c->iri.query)) != NULL) {
+ pct_decode_str(qs);
+ fcgi_send_param(c->cgibev, "GEMINI_SEARCH_STRING", qs);
+ free(qs);
+ }
+
TAILQ_FOREACH(p, &c->host->params, envs) {
fcgi_send_param(c->cgibev, p->name, p->value);
}