summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-12-06 14:30:44 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-12-06 14:30:44 +0200
commit90472c8c7475837545b827dc7f6c9d273633621e (patch)
treed267a3140f788ff5a49a77497d8a81f5e5500afd
parent10d5a1ea2ded21623d1abcb6a955f5098faad334 (diff)
MimeHooks: Request URL via environment variable
IssueID #90
-rw-r--r--res/about/help.gmi2
-rw-r--r--src/gmrequest.c3
2 files changed, 3 insertions, 2 deletions
diff --git a/res/about/help.gmi b/res/about/help.gmi
index 5e9ececd..f71f5164 100644
--- a/res/about/help.gmi
+++ b/res/about/help.gmi
@@ -337,7 +337,7 @@ Example use cases:
337 337
338## Interface 338## Interface
339 339
340When a hook is called, it is given the MIME type and parameters via command line arguments. The response body is provided via stdin. 340When a hook is called, it is given the MIME type and parameters via command line arguments. The response body is provided via stdin. The request's URL is available in the REQUEST_URL environment variable.
341 341
342The MIME type and parameters are split at semicolons, so "text/gemini; lang=ja" would be called as: 342The MIME type and parameters are split at semicolons, so "text/gemini; lang=ja" would be called as:
343``` 343```
diff --git a/src/gmrequest.c b/src/gmrequest.c
index 2402cc40..fe026a5b 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -262,7 +262,8 @@ static void requestFinished_GmRequest_(iGmRequest *d, iTlsRequest *req) {
262 checkServerCertificate_GmRequest_(d); 262 checkServerCertificate_GmRequest_(d);
263 unlock_Mutex(d->mtx); 263 unlock_Mutex(d->mtx);
264 /* Check for mimehooks. */ 264 /* Check for mimehooks. */
265 if (d->isRespFiltered && d->state == finished_GmRequestState) { 265 if (d->isRespFiltered && d->state == finished_GmRequestState) {
266 setenv("REQUEST_URL", cstr_String(&d->url), 1);
266 iBlock *xbody = tryFilter_MimeHooks(mimeHooks_App(), &d->resp->meta, &d->resp->body); 267 iBlock *xbody = tryFilter_MimeHooks(mimeHooks_App(), &d->resp->meta, &d->resp->body);
267 if (xbody) { 268 if (xbody) {
268 lock_Mutex(d->mtx); 269 lock_Mutex(d->mtx);