BIND 10 trac547-summarized, updated. 5a6f9f8c21674d8f70fe33de2b7d7e23c105e888 [trac547] - changed the redirection 302 would be responded only when it's requested with '/' and there is a Host header, in other cases, 404(NotFound) would be responded. - added more description into the document according to the above change - added grammatical fix into the document - regenerated the manpage

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Apr 22 11:39:29 UTC 2011


The branch, trac547-summarized has been updated
       via  5a6f9f8c21674d8f70fe33de2b7d7e23c105e888 (commit)
       via  5573b0bc953d1a9589d2e0f06b8da58dadb64bc3 (commit)
       via  b1cb4c4a1421bb512d093690c95d27425b33e1e5 (commit)
       via  521c140da800fdb7a7c87e53e01270e02ae4bce2 (commit)
      from  7b1677584cd0cc94825741792f9ed66f16029938 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5a6f9f8c21674d8f70fe33de2b7d7e23c105e888
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Fri Apr 22 20:34:08 2011 +0900

    [trac547]
     - changed the redirection
       302 would be responded only when it's requested with '/' and there is a Host
       header, in other cases, 404(NotFound) would be responded.
     - added more description into the document according to the above change
     - added grammatical fix into the document
     - regenerated the manpage

commit 5573b0bc953d1a9589d2e0f06b8da58dadb64bc3
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Fri Apr 22 19:32:38 2011 +0900

    Revert "[trac547] removed unexpected HTTP redirection"
    
    This reverts commit d7cf894e555a8aa8508f695fabac2061822d454d.

commit b1cb4c4a1421bb512d093690c95d27425b33e1e5
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Fri Apr 22 19:32:14 2011 +0900

    [trac547] added more tests into test_open_template
     - checking the type of object returned from open_template method
     - checking the string values replaced by the substitute method in string.Template

commit 521c140da800fdb7a7c87e53e01270e02ae4bce2
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Fri Apr 22 19:04:22 2011 +0900

    [trac547] removed the parts of subscription/unsubscription for the stats module

-----------------------------------------------------------------------

Summary of changes:
 src/bin/stats/b10-stats-httpd.8             |    4 +-
 src/bin/stats/b10-stats-httpd.xml           |    8 ++++-
 src/bin/stats/stats_httpd.py.in             |   22 ++++++++-------
 src/bin/stats/tests/b10-stats-httpd_test.py |   37 ++++++++++++++++++++++----
 4 files changed, 51 insertions(+), 20 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/stats/b10-stats-httpd.8 b/src/bin/stats/b10-stats-httpd.8
index e17c976..c066f91 100644
--- a/src/bin/stats/b10-stats-httpd.8
+++ b/src/bin/stats/b10-stats-httpd.8
@@ -37,7 +37,7 @@ b10-stats-httpd \- BIND 10 HTTP server for HTTP/XML interface of statistics
 
 \fBb10\-stats\-httpd\fR
 is a standalone HTTP server\&. It is intended for HTTP/XML interface for statistics module\&. This server process runs as a process separated from the process of the BIND 10 Stats daemon (\fBb10\-stats\fR)\&. The server is initially executed by the BIND 10 boss process (\fBbind10\fR) and eventually exited by it\&. The server is intended to be server requests by HTTP clients like web browsers and third\-party modules\&. When the server is asked, it requests BIND 10 statistics data from
-\fBb10\-stats\fR, and it sends the data back in Python dictionary format and the server converts it into XML format\&. The server sends it to the HTTP client\&. The server can send three types of document, which are XML (Extensible Markup Language), XSD (XML Schema definition) and XSL (Extensible Stylesheet Language)\&. The XML document is the statistics data of BIND 10, The XSD document is the data schema of it, and The XSL document is the style sheet to be showed for the web browsers\&. Please see the manual and the spec file of
+\fBb10\-stats\fR, and it sends the data back in Python dictionary format and the server converts it into XML format\&. The server sends it to the HTTP client\&. The server can send three types of document, which are XML (Extensible Markup Language), XSD (XML Schema definition) and XSL (Extensible Stylesheet Language)\&. The XML document is the statistics data of BIND 10, The XSD document is the data schema of it, and The XSL document is the style sheet to be showed for the web browsers\&. There is different URL for each document\&. But please note that you would be redirected to the URL of XML document if you request the URL of the root document\&. For example, you would be redirected to http://127\&.0\&.0\&.1:8000/bind10/statistics/xml if you request http://127\&.0\&.0\&.1:8000/\&. Please see the manual and the spec file of
 \fBb10\-stats\fR
 for more details about the items of BIND 10 statistics\&. The server uses CC session in communication with
 \fBb10\-stats\fR\&. CC session is provided by
@@ -92,7 +92,7 @@ to listen HTTP requests on\&. The pair consists of the
 string and
 \fIport\fR
 number\&. The default setting is the list of address 127\&.0\&.0\&.1 port 8000\&. If the server is started by the default setting being left, for example, the URL for XML document is http://127\&.0\&.0\&.1:8000/bind10/statistics/xml\&. And also IPv6 addresses can be configured and they works in the runtime environment for dual stack\&. You can change the settings through
-bindctl(8)
+bindctl(8)\&.
 .RE
 .PP
 The commands in
diff --git a/src/bin/stats/b10-stats-httpd.xml b/src/bin/stats/b10-stats-httpd.xml
index 0f17775..5cf3b4b 100644
--- a/src/bin/stats/b10-stats-httpd.xml
+++ b/src/bin/stats/b10-stats-httpd.xml
@@ -65,7 +65,11 @@
       and XSL (Extensible Stylesheet Language). The XML document is the
       statistics data of BIND 10, The XSD document is the data schema of it,
       and The XSL document is the style sheet to be showed for the web
-      browsers. Please see the manual and the spec file
+      browsers. There is different URL for each document. But please note that
+      you would be redirected to the URL of XML document if you request the URL
+      of the root document. For example, you would be redirected to
+      http://127.0.0.1:8000/bind10/statistics/xml if you request
+      http://127.0.0.1:8000/. Please see the manual and the spec file
       of <command>b10-stats</command> for more details about the items of BIND
       10 statistics. The server uses CC session in communication
       with <command>b10-stats</command>. CC session is provided
@@ -145,7 +149,7 @@
 	    is http://127.0.0.1:8000/bind10/statistics/xml. And also IPv6
 	    addresses can be configured and they works in the runtime
 	    environment for dual stack. You can change the settings
-	    through <refentrytitle>bindctl</refentrytitle><manvolnum>8</manvolnum>
+	    through <refentrytitle>bindctl</refentrytitle><manvolnum>8</manvolnum>.
 	  </para>
         </listitem>
       </varlistentry>
diff --git a/src/bin/stats/stats_httpd.py.in b/src/bin/stats/stats_httpd.py.in
index 38f02b3..20c3442 100644
--- a/src/bin/stats/stats_httpd.py.in
+++ b/src/bin/stats/stats_httpd.py.in
@@ -83,8 +83,18 @@ class HttpHandler(http.server.BaseHTTPRequestHandler):
             elif self.path == XSL_URL_PATH:
                 body = self.server.xsl_handler()
             else:
-                self.send_error(404)
-                return None
+                if self.path == '/' and 'Host' in self.headers.keys():
+                    # redirect to XML URL only when requested with '/'
+                    self.send_response(302)
+                    self.send_header(
+                        "Location",
+                        "http://" + self.headers.get('Host') + XML_URL_PATH)
+                    self.end_headers()
+                    return None
+                else:
+                    # Couldn't find HOST
+                    self.send_error(404)
+                    return None
         except StatsHttpdError as err:
             self.send_error(500)
             if self.server.verbose:
@@ -167,9 +177,6 @@ class StatsHttpd:
         self.stats_module_spec = isc.config.module_spec_from_file(STATS_SPECFILE_LOCATION)
         self.stats_config_spec = self.stats_module_spec.get_config_spec()
         self.stats_module_name = self.stats_module_spec.get_module_name()
-        if self.verbose:
-            self.write_log("[b10-stats-httpd] Starts to subscribe stats module\n")
-        self.cc_session.group_subscribe(self.stats_module_name, "*")
 
     def close_mccs(self):
         """Closes a ModuleCCSession object"""
@@ -177,11 +184,6 @@ class StatsHttpd:
             return
         if self.verbose:
             self.write_log("[b10-stats-httpd] Closing CC Session\n")
-        try:
-            self.cc_session.group_unsubscribe(self.stats_module_name, "*")
-        except isc.cc.session.SessionError as se:
-            if self.verbose:
-                self.write_log("[b10-stats-httpd] Failed to unsubscribe stats module\n")
         self.mccs.close()
         self.mccs = None
 
diff --git a/src/bin/stats/tests/b10-stats-httpd_test.py b/src/bin/stats/tests/b10-stats-httpd_test.py
index 71ee2b4..07999ea 100644
--- a/src/bin/stats/tests/b10-stats-httpd_test.py
+++ b/src/bin/stats/tests/b10-stats-httpd_test.py
@@ -112,13 +112,15 @@ class TestHttpHandler(unittest.TestCase):
         for (k, v) in DUMMY_DATA.items():
             self.assertTrue(handler.response.body.find(str(k))>0)
 
-        # 404 NotFound with Host header
+        # 302 redirect
         handler.path = '/'
         handler.headers = {'Host': 'my.host.domain'}
         handler.do_GET()
-        self.assertEqual(handler.response.code, 404)
+        self.assertEqual(handler.response.code, 302)
+        self.assertEqual(handler.response.headers["Location"],
+                         "http://my.host.domain%s" % stats_httpd.XML_URL_PATH)
 
-        # 404 NotFound without Host header
+        # 404 NotFound
         handler.path = '/path/to/foo/bar'
         handler.headers = {}
         handler.do_GET()
@@ -338,9 +340,32 @@ class TestStatsHttpd(unittest.TestCase):
 
     def test_open_template(self):
         # successful conditions
-        self.stats_httpd.open_template(stats_httpd.XML_TEMPLATE_LOCATION)
-        self.stats_httpd.open_template(stats_httpd.XSD_TEMPLATE_LOCATION)
-        self.stats_httpd.open_template(stats_httpd.XSL_TEMPLATE_LOCATION)
+        tmpl = self.stats_httpd.open_template(stats_httpd.XML_TEMPLATE_LOCATION)
+        self.assertTrue(isinstance(tmpl, string.Template))
+        opts = dict(
+            xml_string="<dummy></dummy>",
+            xsd_namespace="http://host/path/to/",
+            xsd_url_path="/path/to/",
+            xsl_url_path="/path/to/")
+        lines = tmpl.substitute(opts)
+        for n in opts:
+            self.assertTrue(lines.find(opts[n])>0)
+        tmpl = self.stats_httpd.open_template(stats_httpd.XSD_TEMPLATE_LOCATION)
+        self.assertTrue(isinstance(tmpl, string.Template))
+        opts = dict(
+            xsd_string="<dummy></dummy>",
+            xsd_namespace="http://host/path/to/")
+        lines = tmpl.substitute(opts)
+        for n in opts:
+            self.assertTrue(lines.find(opts[n])>0)
+        tmpl = self.stats_httpd.open_template(stats_httpd.XSL_TEMPLATE_LOCATION)
+        self.assertTrue(isinstance(tmpl, string.Template))
+        opts = dict(
+            xsl_string="<dummy></dummy>",
+            xsd_namespace="http://host/path/to/")
+        lines = tmpl.substitute(opts)
+        for n in opts:
+            self.assertTrue(lines.find(opts[n])>0)
         # unsuccessful condition
         self.assertRaises(
             IOError,




More information about the bind10-changes mailing list