Inline script: How to save values from modified request to access it by response?

Hello,
I want to access a original value in the response method (e.g. the flow.request.pretty_url), which I modify during the method request. So when I modify it, the original e.g. URL is lost and I can’t access it.

Example:

def request(flow: http.HTTPFlow) -> None:
    original_value = flow.request.pretty_url
    flow.request.url = "<other/url>"

def response(flow: http.HTTPFlow) -> None:
    x = original_value

Have a look at this: https://github.com/mitmproxy/mitmproxy/blob/master/examples/simple/add_header_class.py

You can do something like:

class Addon:
    self.original_value = None
    def request(self, flow: http.HTTPFlow) -> None:
        self.original_value = flow.request.pretty_url
        flow.request.url = "<other/url>"
    def response(self, flow: http.HTTPFlow) -> None:
        x = self.original_value
addons = [Addon()]