FiddlerScript how can i loop inside OnBeforeRequest or use oSession inside "my" static function ?

2 posts, 0 answers
  1. Nightshades
    Nightshades avatar
    5 posts
    Member since:
    Dec 2015

    Posted 03 Apr 2017 Link to this post

    Hello Telerik, i'm encountering issue and the post of the title is self explanatory i added this code inside "OnBeforeRequest";

    I didn't included all the headers it wasn't needed, the request itself is fine but the problem is that each of my variables are constantly re-initialized since it's inside OnBeforeRequest and i can't use anything like a "for" to loop.

    What i need to do is to make a function that wait "https://testAPI.trylobby.info/online_1v1/start/" to be intercepted (HTTPS POST) this should read the Request body (room_id) send another request and "this" 4 times, i have try to create a new function but when i use var oSession = Fiddler.Session; it return me an error.

    How can i simply use a damn "for" loop inside OnBeforeRequest without having my variable reset each time ? The thing is that i have more than 1 Client and it's kinda complex since it will receive more than 1 time the same request, while i also need to read the room_id each time the request is sent, if it's an already used id then don't send anything, for that i need to read the body of each request or make an array, but again the array is always "cleaned" due to the variable reset each time in the function so Hummm.

    Any help would be appreciated, thank you and awesome software since years :) .

    if(m_UseMSA) //This is a rule
            {
                var CurrentRoom = "";
                var UsedRoom = new Array;
                var i = 0;
                if(oSession.uriContains("https://testAPI.trylobby.info/online_1v1/start/"))
                {
                    oSession.utilDecodeRequest();
                    var Body = System.Text.Encoding.UTF8.GetString(oSession.requestBodyBytes);
                    if(i<5)
                    {
                        var BodyAsByte: byte[] = System.Text.Encoding.UTF8.GetBytes(Body);
                        var request: HTTPRequestHeaders = new HTTPRequestHeaders("/online_1on1/battle_start/",[Header1,Header2,Header3,Header4,Header5,Header6,Header7,Header8,Header9,Header10,Header11,Header12,'Content-Length: ' + Body.Length.ToString()]);
                        request.HTTPMethod = "POST";
                        request.UriScheme = "https";
                    
                        var Dictionary = new System.Collections.Specialized.StringDictionary();
                        var newSession = FiddlerApplication.oProxy.SendRequestAndWait(request,BodyAsByte,Dictionary,null);
                        if(200 == newSession.responseCode)
                        {
                            i++;
                        }
                        
                    }
                    //FiddlerObject.alert(UsedRoom[0]);
                }
            }

     

  2. Nightshades
    Nightshades avatar
    5 posts
    Member since:
    Dec 2015

    Posted 03 Apr 2017 in reply to Nightshades Link to this post

    Well don't know if it's the best way but i managed to do what i wanted using oSession.RequestHeaders.ExistsAndEquals

    while sending a modified header, that way it worked, you can post a better solution or close the post i guess.

Back to Top