support gophers:// by falling back to a plain-text connection (for now) - gophe… | |
git clone git://git.codemadness.org/gopherproxy-c | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 21855e485f7a47b90546f9039fec6a4b4f382567 | |
parent ec71ea5200ff67c6c121dca56c8e50772488163c | |
Author: Hiltjo Posthuma <[email protected]> | |
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(-) | |
--- | |
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", stdou… | |
} | |
+ /* 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://") … | |
+ 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"); |