from pappyproxy.session import Session MACRO_NAME = '{{macro_name}}' SHORT_NAME = '{{short_name}}' runargs = [] def init(args): global runargs runargs = args def modify_header(msg, key, val): """ Modifies the header in a request or a response if it already exists in the message """ if key in msg.headers: msg.headers[key] = val def mangle_request(request): global runargs modify_header(request, 'headername', 'headerval') return request def mangle_response(request): global runargs modify_header(request.response, 'headername', 'headerval') return request.response