'What if mitmproxy7 has no change_upstream_proxy_server?

What if mitmproxy7 has no change_upstream_proxy_server? what to replace?

#  mitmproxy.py
class Proxy:
    def __init__(self):
        pass

    def request(self, flow):
        if 'stackoverflow.com' in flow.request.url:
            # ctx.log.info(flow.request.url)
            proxy = ("127.0.0.1", 8081)
        else:
            proxy = ("127.0.0.1", 8082)

        if flow.live:
            flow.live.change_upstream_proxy_server(proxy)

test2

#  mitmproxy.py
class Proxy:
    def __init__(self):
        pass

    def request(self, flow):
        if 'stackoverflow.com' in flow.request.url:
            # ctx.log.info(flow.request.url)
            proxy = ("127.0.0.1", 8081)
            flow.live.change_upstream_proxy_server(proxy)
        else:
            proxy = ("127.0.0.1", 8082)
        flow.live.change_upstream_proxy_server(proxy)
mitmweb.exe  --mode upstream:http://127.0.0.1:8080/ -s mitmproxy.py

errinfo

AttributeError: 'NoneType' object has no attribute 'change_upstream_proxy_server'



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source