Ejemplo n.º 1
0
 def request(self, flow: HTTPFlow):
     if flow.request.host == 'dummy-upstream':
         flow.error = Error('No upstream is configured.')
         flow.response = make_error_response(
             400,
             'No upstream is configured.',
         )
Ejemplo n.º 2
0
 def request(self, flow: HTTPFlow):
     # Remove "vgs-client" header, that is sent by VGS-Collect.
     # This copies logic from proxy
     flow.request.headers.pop('vgs-client', None)
     if flow.request.host == 'dummy-upstream':
         flow.error = Error('No upstream is configured.')
         flow.response = make_error_response(
             400,
             'No upstream is configured.',
         )
Ejemplo n.º 3
0
    def test_flow_with_error(self):
        flow = load_flow('http_raw')
        flow.error = Error('Test error', datetime.utcnow().timestamp())
        self.proxy_manager.get_flow = Mock(return_value=flow)

        response = self.fetch(self.get_url(f'/flows/{flow.id}'))

        self.assertEqual(response.code, 200)
        response_data = json.loads(response.body)
        self.assertEqual(response_data['error'], {
            'msg': flow.error.msg,
            'timestamp': flow.error.timestamp,
        })
Ejemplo n.º 4
0
    def request(self, flow: http.HTTPFlow):
        if "mitm.it" in flow.request.url:
            return

        data = flow.request.data.content.decode("UTF-8")
        if not len(data):
            data = None
        req = Request(flow.request.method, flow.request.url,
                      dict(flow.request.headers), data)
        resp = submit_request(req)

        if resp:
            flow.response = http.HTTPResponse.make(
                resp["status"], resp["body"].encode("UTF-8"), resp["headers"])

        else:
            flow.error = Error("Gameserver did not send response")
            flow.response = http.HTTPResponse.make(
                400, b"The gameserver returned no response for this request.",
                {})
Ejemplo n.º 5
0
 def kill(flow: HTTPFlow):
     # Can't use flow.kill() here because that currently still depends on a reply object.
     flow.error = Error(Error.KILLED_MESSAGE)