support gophers:// by falling back to a plain-text connection (for now) - 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 21855e485f7a47b90546f9039fec6a4b4f382567
(DIR) parent ec71ea5200ff67c6c121dca56c8e50772488163c
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sat, 3 Aug 2024 15:03:47 +0200
support gophers:// by falling back to a plain-text connection (for now)
Diffstat:
M gopherproxy.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/gopherproxy.c b/gopherproxy.c
@@ -59,6 +59,8 @@ die(int code, const char *fmt, ...)
fputs("Content-Type: text/plain; charset=utf-8\r\n\r\n", stdout);
}
+ /* write error to stderr and stdout */
+
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
@@ -609,6 +611,9 @@ main(void)
if (!strncmp(query, "gopher://", sizeof("gopher://") - 1)) {
showuri = query + sizeof("gopher://") - 1;
r = snprintf(fulluri, sizeof(fulluri), "%s", query);
+ } else if (!strncmp(query, "gophers://", sizeof("gophers://") - 1)) {
+ showuri = query + sizeof("gophers://") - 1;
+ r = snprintf(fulluri, sizeof(fulluri), "%s", query);
} else {
showuri = query;
if (uri_hasscheme(query))
@@ -622,7 +627,7 @@ main(void)
uri_parse(fulluri, &u) == -1)
die(400, "Invalid or unsupported URI: %s\n", showuri);
- if (strcmp(u.proto, "gopher://"))
+ if (strcmp(u.proto, "gopher://") && strcmp(u.proto, "gophers://"))
die(400, "Invalid protocol: only gopher is supported\n");
if (u.host[0] == '\0')
die(400, "Invalid hostname\n");