]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4188. [bug] Support HTTP/1.0 client properly on the statistics
authorMark Andrews <marka@isc.org>
Wed, 19 Aug 2015 23:55:28 +0000 (09:55 +1000)
committerMark Andrews <marka@isc.org>
Wed, 19 Aug 2015 23:56:03 +0000 (09:56 +1000)
                        channel. [RT #40261]

(cherry picked from commit 18ba804f3ab6a7fea10404bb6675a49b59a153c5)

CHANGES
lib/isc/httpd.c

diff --git a/CHANGES b/CHANGES
index ddd7fd3d9a9a57c84069ad9822c7d7f8aaf5f91a..92ae2e02312bc4611c1f1c133ba896665bc886a0 100644 (file)
--- 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,
index f488388e752f4a994bdb6787c5a02f15b3da41c8..9857538a384737253a16d2c27c154add9b566dc0 100644 (file)
@@ -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);