Found the solution myself:
In the BeforeRequest
callback, a Fiddler.Session
object is passed as an argument.
When calling its utilCreateResponseAndBypassServer
function, the request is not relayed to any server but handled locally.
So, my new ParseRequest
function is as follow:
private static void ParseRequest(Session oSession)
{
if (oSession.hostname != "localhost") return;
Console.WriteLine("Handling local request...");
oSession.bBufferResponse = true;
oSession.utilCreateResponseAndBypassServer();
oSession.oResponse.headers.HTTPResponseStatus = "200 Ok";
oSession.oResponse["Content-Type"] = "text/html; charset=UTF-8";
oSession.oResponse["Cache-Control"] = "private, max-age=0";
oSession.utilSetResponseBody("<html><body>Handling local request...</body></html>");
}