output correct HTML on error when dir handling - gopherproxy-c - Gopher HTTP proxy in C (CGI) (HTM) git clone git://git.codemadness.org/gopherproxy-c (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit 4e8119f7c820b0898e1c07b41dabe1b8c72318f8 (DIR) parent 84b61467b8eb24067b1d4bcf306edfb65c0e5c3d (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org> Date: Thu, 30 Aug 2018 21:42:00 +0200 output correct HTML on error when dir handling thanks sdk for noticing and reporting it! Diffstat: M gopherproxy.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- (DIR) diff --git a/gopherproxy.c b/gopherproxy.c @@ -32,7 +32,7 @@ struct visited { char port[8]; }; -int headerset = 0; +int headerset = 0, isdir = 0; void die(int code, const char *fmt, ...) @@ -62,6 +62,9 @@ die(int code, const char *fmt, ...) vfprintf(stdout, fmt, ap); va_end(ap); + if (isdir) + fputs("</pre>\n</body>\n</html>\n", stdout); + exit(1); } @@ -581,7 +584,7 @@ main(void) } } - headerset = 1; + headerset = isdir = 1; fputs( "Content-Type: text/html; charset=utf-8\r\n" "\r\n"