mitmproxy/test/handler.py

25 lines
784 B
Python
Raw Normal View History

2010-02-16 04:09:07 +00:00
import socket
from BaseHTTPServer import BaseHTTPRequestHandler
class TestRequestHandler(BaseHTTPRequestHandler):
default_request_version = "HTTP/1.1"
def setup(self):
self.connection = self.request
self.rfile = socket._fileobject(self.request, "rb", self.rbufsize)
self.wfile = socket._fileobject(self.request, "wb", self.wbufsize)
def log_message(self, *args, **kwargs):
2011-03-05 22:21:31 +00:00
# Silence output
2010-02-16 04:09:07 +00:00
pass
def do_GET(self):
data = "data: %s\npath: %s\n"%(self.headers, self.path)
self.send_response(200)
self.send_header("proxtest", "testing")
self.send_header("Content-type", "text-html")
self.send_header("Content-length", len(data))
self.end_headers()
self.wfile.write(data)