Exemplo n.º 1
0
    def resp(self):
        f = self.req()

        headers = flow.ODictCaseless()
        headers["header_response"] = ["svalue"]
        f.response = http.HTTPResponse((1, 1), 200, "OK", headers, "content_response", None, None)

        return f
Exemplo n.º 2
0
    def resp(self):
        f = self.req()

        headers = Headers([["header_response", "svalue"]])
        f.response = http.HTTPResponse((1, 1), 200, "OK", headers,
                                       "content_response", None, None)

        return f
Exemplo n.º 3
0
def tresp(content="message"):
    """
    @return: libmproxy.protocol.http.HTTPResponse
    """

    headers = odict.ODictCaseless()
    headers["header_response"] = ["svalue"]

    resp = http.HTTPResponse((1, 1), 200, "OK", headers, content, time(),
                             time())
    return resp
Exemplo n.º 4
0
def tresp(req=None, content="message"):
    if not req:
        req = treq()
    f = req.flow

    headers = flow.ODictCaseless()
    headers["header_response"] = ["svalue"]
    cert = certutils.SSLCert.from_der(
        file(test_data.path("data/dercert"), "rb").read())
    f.server_conn = ServerConnection._from_state(
        dict(address=dict(address=("address", 22), use_ipv6=True),
             source_address=None,
             cert=cert.to_pem()))
    f.response = http.HTTPResponse((1, 1), 200, "OK", headers, content, time(),
                                   time())
    f.response.reply = controller.DummyReply()
    return f.response
Exemplo n.º 5
0
def request(context, flow):
    if not flow.request.host == "opsen-static.dolphin-browser.com" \
            or not flow.request.path.endswith(".dwp"):
        return

    # Build response
    #
    response = http.HTTPResponse(
        [1, 1], 200, "OK",
        odict.ODictCaseless([["Content-Type", "application/zip"]]), "yo!")
    # Inject theme
    #
    try:
        with open("Red_roof.dwp", "r") as f:
            modified = f.read()
            response.content = modified
            response.headers["Content-Length"] = [len(modified)]
            f.close()
    except IOError as e:
        raise e

    # Return response
    #
    flow.reply(response)