Modify Request Headers

141 views
Skip to first unread message

kpanic

unread,
Oct 19, 2011, 4:45:12 AM10/19/11
to membrane-monitor
Hi,

Is it possible to modify http request headers with membrane monitor?

Thank you!

Simon

Tobias Polley

unread,
Oct 20, 2011, 7:46:40 AM10/20/11
to membrane-monitor
Hi Simon,

of course; you can either do it

* once manually: capture an Exchange in the Monitor, select it, and
edit the request headers in the bottom half of the main window. Left-
click and "Add" there to add new headers. When done, click "Resend" to
resubmit the modified request to the server.

* automated: using a Groovy script in the service proxy configuration,
for example as shown below. First add a proxy, then "Edit" it to put
the Groovy code into its configuration.

<?xml version = "1.0" ?>
<serviceProxy name="" port="2000">
<request>
<groovy>
def oldValue = exc.request.header.getFirstValue("User-Agent")
exc.request.header.setValue("User-Agent", oldValue.replace("F",
"G"))
exc.request.header.removeFields("Accept-Encoding")
exc.request.header.add("new-header", "foo")
</groovy>
</request>
<target host="predic8.de" port="80" />
</serviceProxy>

Best, Tobias

kpanic

unread,
Oct 25, 2011, 10:47:40 AM10/25/11
to membrane-monitor
Very good, thank you!

Best, Simon
Reply all
Reply to author
Forward
0 new messages