# Path: chirp/common/http.py
# _GET_REQUEST = """GET %(path)s HTTP/1.1
# User-Agent: chirp.common.http
# Host: %(host)s:%(port)d
# Accept: */*
# Connection: close
# 
# """.replace("\n", "\r\n")
# _READ_SIZE = 4096
# def get_with_timeout(host, port, path, timeout_s):
# 
# Path: chirp/stream/barix.py
# def _remove_tags(html_str):
#     def __init__(self, host, port):
#     def ping(self):
# _CLIENT_RE = re.compile("(\d+\.\d+\.\d+\.\d+):src port (\d+) :dst port (\d+)")
#     TIMEOUT_S = 1.0
# class Barix(object):


import unittest
from chirp.common import http
from chirp.stream import barix
        
<img src=d1.gif width=28 height=12>&nbsp;<br>
        
<img src=d1.gif width=28 height=12>&nbsp;<br>
        
<img src=d1.gif width=28 height=12>&nbsp;<br>
        
<img src=d1.gif width=28 height=12>&nbsp;<br>
        
        -->
</body>
</html>
"""

_TEST_CLIENTS_PAGE = """<html><head><meta http-equiv=refresh content="2; url=clients.cgi"></head><body>
<h3>BRTP clients: 0</h3><pre></pre><h3>TCP connections</h3><pre>64.81.140.198:src port 80 :dst port 43624
216.235.91.36:src port 11111 :dst port 52770
192.168.80.10:src port 22222 :dst port 60320
10.0.99.98:src port 33333 :dst port 42911
</pre></body></html>
"""

def _mock_get_with_timeout(host, port, path, timeout_s):
    if path == "/clients.cgi":
        return _TEST_CLIENTS_PAGE
    if path == "/uistatusl.html":
        return _TEST_STATUS_PAGE
    assert False

# Monkey-patch in our mock of get_with_timeout.

# Path: chirp/common/http.py
# _GET_REQUEST = """GET %(path)s HTTP/1.1
# User-Agent: chirp.common.http
# Host: %(host)s:%(port)d
# Accept: */*
# Connection: close
# 
# """.replace("\n", "\r\n")
# _READ_SIZE = 4096
# def get_with_timeout(host, port, path, timeout_s):
# 
# Path: chirp/stream/barix.py
# def _remove_tags(html_str):
#     def __init__(self, host, port):
#     def ping(self):
# _CLIENT_RE = re.compile("(\d+\.\d+\.\d+\.\d+):src port (\d+) :dst port (\d+)")
#     TIMEOUT_S = 1.0
# class Barix(object):


# Path: chirp/stream/barix_test.py
import unittest
from chirp.common import http
from chirp.stream import barix

        
<img src=d1.gif width=28 height=12>&nbsp;<br>
        
<img src=d1.gif width=28 height=12>&nbsp;<br>
        
<img src=d1.gif width=28 height=12>&nbsp;<br>
        
<img src=d1.gif width=28 height=12>&nbsp;<br>
        
        -->
</body>
</html>
"""

_TEST_CLIENTS_PAGE = """<html><head><meta http-equiv=refresh content="2; url=clients.cgi"></head><body>
<h3>BRTP clients: 0</h3><pre></pre><h3>TCP connections</h3><pre>64.81.140.198:src port 80 :dst port 43624
216.235.91.36:src port 11111 :dst port 52770
192.168.80.10:src port 22222 :dst port 60320
10.0.99.98:src port 33333 :dst port 42911
</pre></body></html>
"""

def _mock_get_with_timeout(host, port, path, timeout_s):
    if path == "/clients.cgi":
        return _TEST_CLIENTS_PAGE
    if path == "/uistatusl.html":
        return _TEST_STATUS_PAGE
    assert False

# Monkey-patch in our mock of get_with_timeout.

http.get_with_timeout = _mock_get_with_timeout