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

**URL:** <https://discourse.mitmproxy.org/t/inline-script-how-to-save-values-from-modified-request-to-access-it-by-response/511>\
**Category:** help\
**Created:** [June 6, 2017, 12:32pm UTC](https://discourse.mitmproxy.org/t/inline-script-how-to-save-values-from-modified-request-to-access-it-by-response/511 "2017-06-06T12:32:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tino](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@Tino](https://discourse.mitmproxy.org/u/Tino)\
**Post date:** [June 6, 2017, 12:32pm UTC](https://discourse.mitmproxy.org/t/inline-script-how-to-save-values-from-modified-request-to-access-it-by-response/511/1 "2017-06-06T12:32:44Z")

</div>

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:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![ujjwal96](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/ujjwal96/32/111_2.png) [@ujjwal96](https://discourse.mitmproxy.org/u/ujjwal96)\
**Post date:** [June 6, 2017, 1:46pm UTC](https://discourse.mitmproxy.org/t/inline-script-how-to-save-values-from-modified-request-to-access-it-by-response/511/2 "2017-06-06T13:46:13Z")

</div>

Have a look at this: [https://github.com/mitmproxy/mitmproxy/blob/master/examples/simple/add\_header\_class.py](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()]
```
