Ejemplo n.º 1
0
    def handle_rpc(self, request):
        initial_ctx = HttpMethodContext(self.http_transport, request,
                                self.http_transport.app.out_protocol.mime_type)
        initial_ctx.in_string = [request.content.getvalue()]

        contexts = self.http_transport.generate_contexts(initial_ctx)
        p_ctx, others = contexts[0], contexts[1:]
        if p_ctx.in_error:
            return self.handle_error(p_ctx, others, p_ctx.in_error, request)

        else:
            self.http_transport.get_in_object(p_ctx)

            if p_ctx.in_error:
                return self.handle_error(p_ctx, others, p_ctx.in_error, request)
            else:
                self.http_transport.get_out_object(p_ctx)
                if p_ctx.out_error:
                    return self.handle_error(p_ctx, others, p_ctx.out_error, request)

        self.http_transport.get_out_string(p_ctx)

        process_contexts(self.http_transport, others)

        def _cb_request_finished(request):
            request.finish()

        producer = _Producer(p_ctx.out_string, request)
        producer.deferred.addErrback(err).addCallback(_cb_request_finished)
        request.registerProducer(producer, False)

        return NOT_DONE_YET
Ejemplo n.º 2
0
    def __init__(self, app, req_env, content_type):
        HttpMethodContext.__init__(self, app, req_env, content_type)

        self.transport = WsgiTransportContext(req_env, content_type)
        """Holds the WSGI-specific information"""
Ejemplo n.º 3
0
    def __init__(self, app, request, content_type):
        HttpMethodContext.__init__(self, app, request, content_type)

        self.transport.type = 'twisted.web'