diff --git a/CHANGES b/CHANGES index 4b47e1bc54..cc7c1a656d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +4188. [bug] Support HTTP/1.0 client properly on the statistics + channel. [RT #40261] + 4187. [func] When any RR type implementation doesn't implement totext() for the RDATA's wire representation and returns ISC_R_NOTIMPLEMENTED, diff --git a/lib/isc/httpd.c b/lib/isc/httpd.c index f488388e75..9857538a38 100644 --- a/lib/isc/httpd.c +++ b/lib/isc/httpd.c @@ -62,6 +62,7 @@ #define HTTPD_CLOSE 0x0001 /* Got a Connection: close header */ #define HTTPD_FOUNDHOST 0x0002 /* Got a Host: header */ +#define HTTPD_KEEPALIVE 0x0004 /* Got a Connection: Keep-Alive */ /*% http client */ struct isc_httpd { @@ -483,6 +484,13 @@ process_request(isc_httpd_t *httpd, int length) { if (strstr(s, "Host: ") != NULL) httpd->flags |= HTTPD_FOUNDHOST; + if (strncmp(httpd->protocol, "HTTP/1.0", 8) == 0) { + if (strcasestr(s, "Connection: Keep-Alive") != NULL) + httpd->flags |= HTTPD_KEEPALIVE; + else + httpd->flags |= HTTPD_CLOSE; + } + /* * Standards compliance hooks here. */ @@ -597,7 +605,7 @@ render_404(const char *url, isc_httpdurl_t *urlinfo, const char **mimetype, isc_buffer_t *b, isc_httpdfree_t **freecb, void **freecb_args) { - static char msg[] = "No such URL."; + static char msg[] = "No such URL.\r\n"; UNUSED(url); UNUSED(urlinfo); @@ -623,7 +631,7 @@ render_500(const char *url, isc_httpdurl_t *urlinfo, const char **mimetype, isc_buffer_t *b, isc_httpdfree_t **freecb, void **freecb_args) { - static char msg[] = "Internal server failure."; + static char msg[] = "Internal server failure.\r\n"; UNUSED(url); UNUSED(urlinfo); @@ -726,6 +734,8 @@ isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev) { } isc_httpd_response(httpd); + if ((httpd->flags & HTTPD_KEEPALIVE) != 0) + isc_httpd_addheader(httpd, "Connection", "Keep-Alive"); isc_httpd_addheader(httpd, "Content-Type", httpd->mimetype); isc_httpd_addheader(httpd, "Date", datebuf); isc_httpd_addheader(httpd, "Expires", datebuf);