for the gif type set Content-Type explicitly, try image detection by extension … | |
git clone git://git.codemadness.org/gopherproxy-c | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 328eee3a3a6814914911e25e3447adb9cc09f4ba | |
parent 2188db7bb8e13eb43c8e61376baf0381be3af513 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Fri, 17 Aug 2018 16:01:10 +0200 | |
for the gif type set Content-Type explicitly, try image detection by extension | |
Diffstat: | |
M gopherproxy.c | 26 +++++++++++++++++++++++--- | |
1 file changed, 23 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/gopherproxy.c b/gopherproxy.c | |
@@ -526,14 +526,34 @@ main(void) | |
headerset = 1; | |
switch (_type) { | |
+ case '1': | |
+ case '7': | |
+ break; /* handled below */ | |
case '0': | |
dprintf(1, "Content-Type: text/plain; charset=utf-8\r\… | |
servefile(u.host, u.port, path); | |
return 0; | |
- case '1': | |
- case '7': | |
- break; /* handled below */ | |
+ case 'g': | |
+ dprintf(1, "Content-Type: image/gif\r\n\r\n"); | |
+ servefile(u.host, u.port, path); | |
+ return 0; | |
+ case 'I': | |
+ /* try to set Content-Type based on extension */ | |
+ if ((p = strrchr(path, '.'))) { | |
+ p++; | |
+ if (!strcasecmp("png", p)) { | |
+ dprintf(1, "Content-Type: image/png\r\… | |
+ } else if (!strcasecmp("jpg", p) || !strcasecm… | |
+ dprintf(1, "Content-Type: image/jpeg\r… | |
+ } else if (!strcasecmp("gif", p)) { | |
+ dprintf(1, "Content-Type: image/gif\r\… | |
+ } | |
+ } | |
+ write(1, "\r\n", 2); | |
+ servefile(u.host, u.port, path); | |
+ return 0; | |
case '9': | |
+ /* try to detect filename */ | |
if ((p = strrchr(path, '/'))) | |
dprintf(1, "Content-Disposition: attachment; f… | |
dprintf(1, "Content-Type: application/octet-stream\r\n… |