'mock response'

def handle(self, handler, status=400, headers={}, body=''):

    logging.info('%s    "MOCK    %s    %s    %s"    %d    %d', handler.address_string(), handler.command, handler.path, handler.protocol_version, status, len(body))
    headers = dict(((k.title(), v) for (k, v) in headers.items()))
    if ('Transfer-Encoding' in headers):
        del headers['Transfer-Encoding']
    if ('Content-Length' not in headers):
        headers['Content-Length'] = len(body)
    if ('Connection' not in headers):
        headers['Connection'] = 'close'
    handler.send_response(status)
    for (key, value) in headers.items():
        handler.send_header(key, value)
    handler.end_headers()
    handler.wfile.write(body)
