This is a migrated thread and some comments may be shown as answers.

How can I safely replace a query string with an empty string?

1 Answer 273 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
nasekt
Top achievements
Rank 1
nasekt asked on 14 Sep 2014, 09:49 AM
My Goal:Append +test1+test2+test3 to query, then before data reaches the client's web browser replace +test1+test2+test3 with an empty string.

To append string to query, I used this code

static function OnBeforeRequest(oSession: Session) {

if (oSession.uriContains("www.youtube.com/results?search_query="))
{
var str = oSession.fullUrl;
var sAppend = "+test1+test2+test3";
if (!oSession.uriContains(sAppend))
{
oSession.fullUrl = str + sAppend;
}
}

Everything worked fine, but the problem started after I added this code

static function OnBeforeResponse(oSession: Session) {

if (oSession.HostnameIs("www.youtube.com") && oSession.oResponse.headers.ExistsAndContains("Content-Type","text/html")){
oSession.utilDecodeResponse();
oSession.utilReplaceInResponse('+test1+test2+test3','');

Instead of appending to search_query=, it gets appended to &page=

I'm pretty sure oSession.utilReplaceInResponse is responsible for the problem.I really need help.

Thank you.

1 Answer, 1 is accepted

Sort by
0
nasekt
Top achievements
Rank 1
answered on 14 Sep 2014, 04:26 PM
Solved it! It was a small mistake on my part.
Tags
Fiddler Classic
Asked by
nasekt
Top achievements
Rank 1
Answers by
nasekt
Top achievements
Rank 1
Share this question
or