From 99683cbbd444705e73126e8b12880b897fdb0a18 Mon Sep 17 00:00:00 2001 From: des Date: Tue, 1 Jan 2002 16:25:29 +0000 Subject: In verbose mode, display the full error message from the server, stripping it of HTML tags and comments. PR: bin/32989 MFC after: 1 week --- lib/libfetch/http.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) (limited to 'lib/libfetch/http.c') diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c index 0cd1186..6158968 100644 --- a/lib/libfetch/http.c +++ b/lib/libfetch/http.c @@ -99,6 +99,7 @@ extern char *__progname; /* XXX not portable */ || (xyz) == HTTP_MOVED_TEMP \ || (xyz) == HTTP_SEE_OTHER) +#define HTTP_ERROR(xyz) ((xyz) > 400 && (xyz) < 599) /***************************************************************************** @@ -675,6 +676,42 @@ _http_get_proxy(void) return NULL; } +static void +_http_print_html(FILE *out, FILE *in) +{ + size_t len; + char *line, *p, *q; + int comment, tag; + + comment = tag = 0; + while ((line = fgetln(in, &len)) != NULL) { + while (len && isspace(line[len - 1])) + --len; + for (p = q = line; q < line + len; ++q) { + if (comment && *q == '-') { + if (q + 2 < line + len && strcmp(q, "-->") == 0) { + tag = comment = 0; + q += 2; + } + } if (tag && !comment && *q == '>') { + p = q + 1; + tag = 0; + } else if (!tag && *q == '<') { + if (q > p) + fwrite(p, q - p, 1, out); + tag = 1; + if (q + 3 < line + len && strcmp(q, "