t* gopherproxy-c customized
       
   URI git clone git://git.codevoid.de/gopherproxy-c-sdk
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 328eee3a3a6814914911e25e3447adb9cc09f4ba
   DIR parent 2188db7bb8e13eb43c8e61376baf0381be3af513
   URI Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       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(-)
       ---
   DIR diff --git a/gopherproxy.c b/gopherproxy.c
       t@@ -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\n\r\n");
                                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\n");
       +                                } else if (!strcasecmp("jpg", p) || !strcasecmp("jpeg", p)) {
       +                                        dprintf(1, "Content-Type: image/jpeg\r\n");
       +                                } else if (!strcasecmp("gif", p)) {
       +                                        dprintf(1, "Content-Type: image/gif\r\n");
       +                                }
       +                        }
       +                        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; filename=\"%s\"\r\n", p + 1);
                                dprintf(1, "Content-Type: application/octet-stream\r\n\r\n");