FiddlerApplication.Startup(8887, FiddlerCoreStartupFlags.Default); FiddlerApplication.BeforeResponse +=new SessionStateHandler(delegate (Session oSession) { oSession.bBufferResponse = true; oSession.utilDecodeResponse(); var Body = oSession.GetResponseBodyAsString(); Body = Regex.Replace(Body, @"SomeText", "12345",RegexOptions.Singleline); oSession.utilSetResponseBody(Body); });
Note to FiddlerCore Developers:When the bBufferResponse property on a session is set to false, that session's response is streamed to the client as it is being read from the server. As a consequence, the client has already received the response before the BeforeResponse event has fired. In contrast, if that property is set to true, that Session's response will be buffered until complete, then the BeforeResponse event fires, then the response is sent to the client. The last event guaranteed to fire before the client starts getting response bytes is FiddlerApplication.ResponseHeadersAvailable. You can use that event handler to set the bBufferResponse property if you need to modify the response bytes before the client receives them.