Example #1
0
 internal Session(ClientPipe clientPipe, ServerPipe serverPipe)
 {
     EventHandler<StateChangeEventArgs> handler = null;
     this.bBufferResponse = FiddlerApplication.Prefs.GetBoolPref("fiddler.ui.rules.bufferresponses", false);
     this.Timers = new SessionTimers();
     this._bAllowClientPipeReuse = true;
     this.oFlags = new StringDictionary();
     if (CONFIG.bDebugSpew)
     {
         if (handler == null)
         {
             handler = (s, ea) => FiddlerApplication.DebugSpew(string.Format("onstatechange>#{0} moving from state '{1}' to '{2}' {3}", new object[] { this.id.ToString(), ea.oldState, ea.newState, Environment.StackTrace }));
         }
         this.OnStateChanged += handler;
     }
     if (clientPipe != null)
     {
         this.Timers.ClientConnected = clientPipe.dtAccepted;
         this.m_clientIP = (clientPipe.Address == null) ? null : clientPipe.Address.ToString();
         this.m_clientPort = clientPipe.Port;
         this.oFlags["x-clientIP"] = this.m_clientIP;
         this.oFlags["x-clientport"] = this.m_clientPort.ToString();
         if (clientPipe.LocalProcessID != 0)
         {
             this._LocalProcessID = clientPipe.LocalProcessID;
             this.oFlags["x-ProcessInfo"] = string.Format("{0}:{1}", clientPipe.LocalProcessName, this._LocalProcessID);
         }
     }
     else
     {
         this.Timers.ClientConnected = DateTime.Now;
     }
     this.oResponse = new ServerChatter(this);
     this.oRequest = new ClientChatter(this);
     this.oRequest.pipeClient = clientPipe;
     this.oResponse.pipeServer = serverPipe;
 }
Example #2
0
 public Session(HTTPRequestHeaders oRequestHeaders, byte[] arrRequestBody)
 {
     EventHandler<StateChangeEventArgs> handler = null;
     this.bBufferResponse = FiddlerApplication.Prefs.GetBoolPref("fiddler.ui.rules.bufferresponses", false);
     this.Timers = new SessionTimers();
     this._bAllowClientPipeReuse = true;
     this.oFlags = new StringDictionary();
     if (oRequestHeaders == null)
     {
         throw new ArgumentNullException("oRequestHeaders", "oRequestHeaders must not be null when creating a new Session.");
     }
     if (arrRequestBody == null)
     {
         arrRequestBody = Utilities.emptyByteArray;
     }
     if (CONFIG.bDebugSpew)
     {
         if (handler == null)
         {
             handler = (s, ea) => FiddlerApplication.DebugSpew(string.Format("onstatechange>#{0} moving from state '{1}' to '{2}' {3}", new object[] { this.id.ToString(), ea.oldState, ea.newState, Environment.StackTrace }));
         }
         this.OnStateChanged += handler;
     }
     this.Timers.ClientConnected = this.Timers.ClientBeginRequest = this.Timers.FiddlerGotRequestHeaders = DateTime.Now;
     this.m_clientIP = null;
     this.m_clientPort = 0;
     this.oFlags["x-clientIP"] = this.m_clientIP;
     this.oFlags["x-clientport"] = this.m_clientPort.ToString();
     this.oResponse = new ServerChatter(this);
     this.oRequest = new ClientChatter(this);
     this.oRequest.pipeClient = null;
     this.oResponse.pipeServer = null;
     this.oRequest.headers = oRequestHeaders;
     this.requestBodyBytes = arrRequestBody;
     this.m_state = SessionStates.AutoTamperRequestBefore;
 }
Example #3
0
 public Session(byte[] arrRequest, byte[] arrResponse, SessionFlags oSF)
 {
     HTTPHeaderParseWarnings warnings;
     int num;
     int num2;
     int num3;
     int num4;
     this.bBufferResponse = FiddlerApplication.Prefs.GetBoolPref("fiddler.ui.rules.bufferresponses", false);
     this.Timers = new SessionTimers();
     this._bAllowClientPipeReuse = true;
     this.oFlags = new StringDictionary();
     if (Utilities.IsNullOrEmpty(arrRequest))
     {
         throw new ArgumentException("Missing request data for session");
     }
     if (Utilities.IsNullOrEmpty(arrResponse))
     {
         arrResponse = Encoding.ASCII.GetBytes("HTTP/1.1 0 FIDDLER GENERATED - RESPONSE DATA WAS MISSING\r\n\r\n");
     }
     this.state = SessionStates.Done;
     this.m_requestID = Interlocked.Increment(ref cRequests);
     this.BitFlags = oSF;
     if (!Parser.FindEntityBodyOffsetFromArray(arrRequest, out num, out num2, out warnings))
     {
         throw new InvalidDataException("Request corrupt, unable to find end of headers.");
     }
     if (!Parser.FindEntityBodyOffsetFromArray(arrResponse, out num3, out num4, out warnings))
     {
         throw new InvalidDataException("Response corrupt, unable to find end of headers.");
     }
     this.requestBodyBytes = new byte[arrRequest.Length - num2];
     this.responseBodyBytes = new byte[arrResponse.Length - num4];
     Buffer.BlockCopy(arrRequest, num2, this.requestBodyBytes, 0, this.requestBodyBytes.Length);
     Buffer.BlockCopy(arrResponse, num4, this.responseBodyBytes, 0, this.responseBodyBytes.Length);
     string sData = CONFIG.oHeaderEncoding.GetString(arrRequest, 0, num) + "\r\n\r\n";
     string sHeaders = CONFIG.oHeaderEncoding.GetString(arrResponse, 0, num3) + "\r\n\r\n";
     this.oRequest = new ClientChatter(this, sData);
     this.oResponse = new ServerChatter(this, sHeaders);
 }