From 28a095f7709e07aebd7b32843d787e08369e1568 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 26 Apr 2022 03:23:20 -0500 Subject: [PATCH] Fix wget port and have httpd return http 1.1 so wget recognizes it. --- toys/net/httpd.c | 10 ++++++++-- toys/net/wget.c | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/toys/net/httpd.c b/toys/net/httpd.c index fb84dd92..9e91197a 100644 --- a/toys/net/httpd.c +++ b/toys/net/httpd.c @@ -4,7 +4,13 @@ * * See https://www.ietf.org/rfc/rfc2616.txt * - * TODO: multiple domains, cgi, https, actual inetd with ratelimit... + * TODO: multiple domains, https, actual inetd with ratelimit... + * range, gzip, ETag (If-None-Match:, Last-Modified:), Date: + * "Accept-Ranges: bytes"/"Range: bytes=xxx-[yyy]" + * .htaccess (auth, forward) + * optional conf file, error pages + * -ifv -p [IP:]PORT -u [USER][:GRP] -c CFGFILE + * cgi: SERVER_PORT SERVER_NAME REMOTE_ADDR REMOTE_HOST REQUEST_METHOD USE_HTTPD(NEWTOY(httpd, ">1", TOYFLAG_USR|TOYFLAG_BIN)) @@ -31,7 +37,7 @@ void header_time(int stat, char *str, char *more) { char buf[64]; - xprintf("HTTP/1.0 %d %s\r\nServer: toybox httpd/%s\r\nDate: %s\r\n%s" + xprintf("HTTP/1.1 %d %s\r\nServer: toybox httpd/%s\r\nDate: %s\r\n%s" "Connection: close\r\n\r\n", stat, str, TOYBOX_VERSION, rfc1123(buf, time(0)), more ? : ""); } diff --git a/toys/net/wget.c b/toys/net/wget.c index cfdbb7da..75632646 100644 --- a/toys/net/wget.c +++ b/toys/net/wget.c @@ -103,7 +103,7 @@ static void wget_info(char *url, char **host, char **port, char **path) if (**host=='[' && (ss = strchr(++*host, ']'))) { *ss++ = 0; *port = (*ss==':') ? ++ss : 0; - } else if ((*port = strchr(*host, ':'))) *(*port++) = 0; + } else if ((*port = strchr(*host, ':'))) *((*port)++) = 0; if (!*port) *port = HTTPS ? "443" : "80"; } @@ -272,7 +272,7 @@ void wget_main(void) free(TT.url); TT.url = ss; wget_close(); - } else if (status != 200) error_exit("response: %ld", status); + } else if (status != 200) error_exit("response %ld", status); } // Open output file -- 2.39.2