# Path: chirp/common/http_console_server.py
# DEFAULT_HOST = "localhost"
# DEFAULT_PORT = 9000
#     _TIMEOUT_S = 2.0
# class _RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
# class _HttpConsoleServer(object):
#     def _dispatch(self):
#     def do_GET(self):
#     def do_POST(self):
#     def _send_full_response(self, content_type, body):
#     def send_text(self, body):
#     def send_html(self, body):
#     def log_message(self, format, *args):
# def build_sysinfo_page():
#     def add(key, val):
#     def __init__(self, host, port):
#     def _thread_worker(self):
#     def stop(self):
# def start(host=DEFAULT_HOST, port=DEFAULT_PORT):
# def stop():
# def url(path=None):
# def register(path, handler_fn, require_post=False):


import unittest
import urllib2
            import traceback
from chirp.common import http_console_server
            self.open("/foo")
            self.assertTrue(False)
        except urllib2.URLError, ex:
            self.assertEqual(404, ex.code)

        # Now register a simple page handler and a POST-only handler.
        test_string = "This is not HTML"
        http_console_server.register("/foo", lambda x: test_string)
        post_only_string = "This is only fetchable via a POST"
        http_console_server.register("/bar", lambda x: post_only_string,
                                     require_post=True)

        # Re-registering the same path is not allowed.
        self.assertRaises(ValueError,
                          http_console_server.register,
                          "/foo", lambda x: test_string)

        # We should now be able to hit "/foo" and get back out test string.
        f = self.open("/foo")
        self.assertEqual(test_string, f.read())
        self.assertEqual("text/html", f.info().type)

        # Trying to get /bar with a GET will fail with a 405.
        try:
            self.open("/bar")
            self.assertTrue(False)
        except urllib2.URLError, ex:
            self.assertEqual(405, ex.code)

        # We should be able to fetch /bar if we force a POST.

# Path: chirp/common/http_console_server.py
# DEFAULT_HOST = "localhost"
# DEFAULT_PORT = 9000
#     _TIMEOUT_S = 2.0
# class _RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
# class _HttpConsoleServer(object):
#     def _dispatch(self):
#     def do_GET(self):
#     def do_POST(self):
#     def _send_full_response(self, content_type, body):
#     def send_text(self, body):
#     def send_html(self, body):
#     def log_message(self, format, *args):
# def build_sysinfo_page():
#     def add(key, val):
#     def __init__(self, host, port):
#     def _thread_worker(self):
#     def stop(self):
# def start(host=DEFAULT_HOST, port=DEFAULT_PORT):
# def stop():
# def url(path=None):
# def register(path, handler_fn, require_post=False):


# Path: chirp/common/http_console_server_test.py
import unittest
import urllib2
            import traceback
from chirp.common import http_console_server

            self.open("/foo")
            self.assertTrue(False)
        except urllib2.URLError, ex:
            self.assertEqual(404, ex.code)

        # Now register a simple page handler and a POST-only handler.
        test_string = "This is not HTML"
        http_console_server.register("/foo", lambda x: test_string)
        post_only_string = "This is only fetchable via a POST"
        http_console_server.register("/bar", lambda x: post_only_string,
                                     require_post=True)

        # Re-registering the same path is not allowed.
        self.assertRaises(ValueError,
                          http_console_server.register,
                          "/foo", lambda x: test_string)

        # We should now be able to hit "/foo" and get back out test string.
        f = self.open("/foo")
        self.assertEqual(test_string, f.read())
        self.assertEqual("text/html", f.info().type)

        # Trying to get /bar with a GET will fail with a 405.
        try:
            self.open("/bar")
            self.assertTrue(False)
        except urllib2.URLError, ex:
            self.assertEqual(405, ex.code)

        # We should be able to fetch /bar if we force a POST.

        request = urllib2.Request(http_console_server.url("/bar"), "")