def test_on_headers_complete_passes_request(self):
        global request, on_head_got_request, on_body_got_request

        pipeline = HttpFilterPipeline()
        pipeline.add_filter(ResponseFilterUsesRequest())
        pipeline.add_filter(ResponseFilterDoesNotUseRequest())

        downstream = mock.MagicMock()
        downstream.write = mock.Mock(return_value=None)

        upstream = mock.MagicMock()
        request = mock.Mock()

        handler = UpstreamHandler(downstream, upstream, pipeline, request)
        handler.on_status(200)  # Make response non-empty to prevent errors
        handler.on_headers_complete()
        handler.on_body(bytes="", length=0, is_chunked=False)

        self.assertTrue(on_head_got_request)
        self.assertTrue(on_body_got_request)
    def test_on_headers_complete_passes_request(self):
        global request, on_head_got_request, on_body_got_request

        pipeline = HttpFilterPipeline()
        pipeline.add_filter(ResponseFilterUsesRequest())
        pipeline.add_filter(ResponseFilterDoesNotUseRequest())

        downstream = mock.MagicMock()
        downstream.write = mock.Mock(return_value=None)

        upstream = mock.MagicMock()
        request = mock.Mock()

        handler = UpstreamHandler(downstream, upstream, pipeline, request)
        handler.on_status(200)  # Make response non-empty to prevent errors
        handler.on_headers_complete()
        handler.on_body(bytes='', length=0, is_chunked=False)

        self.assertTrue(on_head_got_request)
        self.assertTrue(on_body_got_request)
Example #3
0
 def new_filter_pipeline():
     pipeline = HttpFilterPipeline()
     for cls in filter_classes:
         pipeline.add_filter(filter_instances[cls.__name__])
     return pipeline
Example #4
0
 def new_filter_pipeline():
     pipeline = HttpFilterPipeline()
     for cls in filter_cls_list:
         pipeline.add_filter(cls())
     return pipeline
Example #5
0
 def new_filter_pipeline():
     pipeline = HttpFilterPipeline()
     for cls in filter_classes:
         pipeline.add_filter(filter_instances[cls.__name__])
     return pipeline
Example #6
0
 def new_filter_pipeline():
     pipeline = HttpFilterPipeline()
     for cls in filter_cls_list:
         pipeline.add_filter(cls())
     return pipeline