cannot send IP address + host header in Request Builder

1,037 views
Skip to first unread message

RB1980

unread,
Feb 7, 2009, 2:17:31 PM2/7/09
to Fiddler
In order to test the response from a particular server, sometimes I
need to send the host header in the request to a URI that points to a
specific server IP.
For example, with curl I do this like:
curl -I -s -H "Host: www.mydomain.com" http://192.168.1.1/index.html

I've tried to replicate this type of request in Fiddler by dragging a
request to the Request Builder and changing the host name in the URL
box to the desired IP and making sure the Host: header is set to
www.mydomain.com in the Request Headers box.
The problem is, that when you hit Execute, Fiddler takes the IP listed
in the URL and re-writes the request header with the IP as the Host:
name.

It would be nice if Fiddler would leave the Host header in the Request
Headers box intact and send the request to the IP listed in the URL.
Perhaps there is a workaround for this? Short of spoofing the host
name every time I want to test a specific server?
Message has been deleted

RB1980

unread,
Feb 7, 2009, 3:05:45 PM2/7/09
to Fiddler
I just read this post: (http://groups.google.com/group/httpfiddler/
browse_thread/thread/f7f2bb6bc4112348) which seems to be
a similar issue. I tried the rule mentioned here and while it works,
it still requires me manually changing the rule every time I want to
test a different server/hostname combination.

I wonder if a similar rule could be constructed to look for an IP
regex in the request and set the x-overrideHostname to that, while
maintaining the Host header as passed in the Request Builder?

RB1980

unread,
Feb 12, 2009, 1:17:32 PM2/12/09
to Fiddler
I think I figured out a pretty easy way I can do this with some
customrules but I am hung up on one piece of the script:
Is there a way to match a regex with oSession.HostnameIs or
oSession.url in OnBeforeRequest?
for example, I've tried these and they didn't seem to work:
if (oSession.HostnameIs("regex:foo.*")
or
if (oSession.url == "regex:foo.*")

is something like this possible?

EricLaw

unread,
Feb 13, 2009, 12:09:11 PM2/13/09
to Fiddler
The script engine supports all JScript.Net constructs. See
www.fiddler2.com/fiddler/dev/scriptsamples.asp for inspiration.

The url is a simple string as is the hostname. You can use normal
regex operations on strings like so:

var oRegEx = /searchterm/gi;
bURIMatches = oRegEx.test(oSession.url);
Reply all
Reply to author
Forward
0 new messages