Allow support to Modify Request & Response Headers dynamically

I want to consume the existing header values while modifying a request or response header. Particularly helpful in modifying cookies. One line of thought is we can provide support for modifying cookies directly.

Or if I can write a small script that allows me to return a new value of the header.