# Path: protector/proxy/request_handler.py
# class ProxyRequestHandler(BaseHTTPRequestHandler):
#     def __init__(self, *args, **kwargs):
#     def log_error(self, log_format, *args):
#     def do_CONNECT(self):
#     def connect_intercept(self):
#     def connect_relay(self):
#     def _check_query(self, query_string):
#     def get_queries(parameters):
#     def _analyze_url(path):
#     def do_GET(self):
#     def _handle_request(self, scheme, netloc, path, headers, body=None, method="GET"):
#     def do_POST(self):
#     def send_error(self, code, message=None):
#     def _return_response(self, response):
#     def filter_headers(headers):
#     def encode_content_body(text, encoding):
#     def decode_content_body(data, encoding):
#     def send_cacert(self):
#     def _build_url(self, path, host):
# 
# Path: protector/proxy/server.py
# class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
#     def server_bind(self):
#     def handle_error(self, request, client_address):


import unittest
import json
import time
import threading
import urllib2
from mock import MagicMock, patch
from result import Ok
from protector.proxy import request_handler
from protector.proxy import server
class MockHTTPResponse(object):
    HTTP_10 = 10
    HTTP_11 = 11

    def __init__(self, status, reason, msg=None, body="", version=HTTP_11, delay=0):
        if msg is None:
            msg = {}
        self.status = status
        self.reason = reason
        self.msg = msg
        self.body = body
        self.version = version
        self.delay = delay

    def read(self):
        if self.delay:
            time.sleep(self.delay)
        return self.body


class TestRequests(unittest.TestCase):
    def setUp(self):
        self.host = "127.0.0.1"
        self.port = 8888
        self.backend_host = "http://www.example.com"
        self.backend_port = 1234

    def start_server(self):
        request_handler.ProxyRequestHandler.protocol_version = "HTTP/1.1"
        request_handler.ProxyRequestHandler.protector = self.create_protector()

# Path: protector/proxy/request_handler.py
# class ProxyRequestHandler(BaseHTTPRequestHandler):
#     def __init__(self, *args, **kwargs):
#     def log_error(self, log_format, *args):
#     def do_CONNECT(self):
#     def connect_intercept(self):
#     def connect_relay(self):
#     def _check_query(self, query_string):
#     def get_queries(parameters):
#     def _analyze_url(path):
#     def do_GET(self):
#     def _handle_request(self, scheme, netloc, path, headers, body=None, method="GET"):
#     def do_POST(self):
#     def send_error(self, code, message=None):
#     def _return_response(self, response):
#     def filter_headers(headers):
#     def encode_content_body(text, encoding):
#     def decode_content_body(data, encoding):
#     def send_cacert(self):
#     def _build_url(self, path, host):
# 
# Path: protector/proxy/server.py
# class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
#     def server_bind(self):
#     def handle_error(self, request, client_address):


# Path: protector/tests/proxy/test_server.py
import unittest
import json
import time
import threading
import urllib2
from mock import MagicMock, patch
from result import Ok
from protector.proxy import request_handler
from protector.proxy import server

class MockHTTPResponse(object):
    HTTP_10 = 10
    HTTP_11 = 11

    def __init__(self, status, reason, msg=None, body="", version=HTTP_11, delay=0):
        if msg is None:
            msg = {}
        self.status = status
        self.reason = reason
        self.msg = msg
        self.body = body
        self.version = version
        self.delay = delay

    def read(self):
        if self.delay:
            time.sleep(self.delay)
        return self.body


class TestRequests(unittest.TestCase):
    def setUp(self):
        self.host = "127.0.0.1"
        self.port = 8888
        self.backend_host = "http://www.example.com"
        self.backend_port = 1234

    def start_server(self):
        request_handler.ProxyRequestHandler.protocol_version = "HTTP/1.1"
        request_handler.ProxyRequestHandler.protector = self.create_protector()

        request_handler.ProxyRequestHandler.backend_address = (self.backend_host, self.backend_port)