From 0976d12b88784d7b78ae66d37b5109362004a1ff Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Wed, 7 Jan 2015 18:40:55 +0000 Subject: [PATCH] Ditch any query strings in HTTP requests before handling them, to allow AJAX requests to tack on a query string to avoid caching. --- net_io.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net_io.c b/net_io.c index 5d2a1a8..2918fba 100644 --- a/net_io.c +++ b/net_io.c @@ -866,6 +866,10 @@ int handleHTTPRequest(struct client *c, char *p) { printf("HTTP requested URL: %s\n\n", url); } + // Ditch any trailing query part (AJAX might add one to avoid caching) + p = strchr(url, '?'); + if (p) *p = 0; + statuscode = 404; for (i = 0; url_handlers[i].path; ++i) { if (!strcmp(url, url_handlers[i].path)) {