Ejemplo n.º 1
0
    def _create_request(self, flow, response=None):
        request = Request(method=flow.request.method,
                          url=flow.request.url,
                          headers=[(k, v)
                                   for k, v in flow.request.headers.items()],
                          body=flow.request.raw_content)
        request.response = response

        return request
Ejemplo n.º 2
0
    def _create_request(self, flow, response=None):
        request = Request(
            method=flow.request.method,
            url=flow.request.url,
            headers=[(k, v) for k, v in flow.request.headers.items()],
            body=flow.request.raw_content
        )

        # For websocket requests, the scheme of the request is overwritten with https
        # in the initial CONNECT request so this hack explicitly sets the scheme back to wss.
        if websockets.check_handshake(request.headers) and websockets.check_client_version(request.headers):
            request.url = request.url.replace('https', 'wss', 1)

        request.response = response

        return request