I have tried editing the rules on fiddler script editor
static function OnBeforeRequest(oSession: Session) {
// Check if the request URL matches a pattern (for example, you can forward requests to a specific domain)
if (oSession.url.Contains("example.com")) {
// Get the request body (as a string)
var requestBody = oSession.GetRequestBodyAsString();
// Parse the request body as JSON
var data = parseJSON(requestBody);
if (data == null) {
// If the data is not valid JSON, handle the error
oSession.ResponseBody = "Invalid JSON received";
oSession.oResponse.headers["Content-Type"] = "text/plain";
return;
}
// Prepare the data to send to the PHP server
var dataToSend = {
"method": oSession.oRequest.headers["Method"],
"url": oSession.url,
"headers": oSession.oRequest.headers.ToString(),
"body": data
};
// Define the PHP server URL (running on localhost:8000)
var phpServerUrl = "http://localhost:8000/process_request.php";
// Prepare HTTP request to send to the PHP server
var oHTTP = new HTTPRequest(phpServerUrl, "POST", stringifyJSON(dataToSend));
// Send the request
var oResponse = oHTTP.Send();
// Handle the PHP server's response
if (oResponse.StatusCode == 200) {
oSession.ResponseBody = oResponse.Body;
oSession.oResponse.headers["Content-Type"] = "application/json";
}
}
}
But the code doesnt work because JSON object is not recordgnized.
Is there any waY I can broadcast/forward all requests captured that belong to example.com domain?>
static function OnBeforeRequest(oSession: Session) {
// Check if the request URL matches a pattern (for example, you can forward requests to a specific domain)
if (oSession.url.Contains("example.com")) {
// Get the request body (as a string)
var requestBody = oSession.GetRequestBodyAsString();
// Parse the request body as JSON
var data = parseJSON(requestBody);
if (data == null) {
// If the data is not valid JSON, handle the error
oSession.ResponseBody = "Invalid JSON received";
oSession.oResponse.headers["Content-Type"] = "text/plain";
return;
}
// Prepare the data to send to the PHP server
var dataToSend = {
"method": oSession.oRequest.headers["Method"],
"url": oSession.url,
"headers": oSession.oRequest.headers.ToString(),
"body": data
};
// Define the PHP server URL (running on localhost:8000)
var phpServerUrl = "http://localhost:8000/process_request.php";
// Prepare HTTP request to send to the PHP server
var oHTTP = new HTTPRequest(phpServerUrl, "POST", stringifyJSON(dataToSend));
// Send the request
var oResponse = oHTTP.Send();
// Handle the PHP server's response
if (oResponse.StatusCode == 200) {
oSession.ResponseBody = oResponse.Body;
oSession.oResponse.headers["Content-Type"] = "application/json";
}
}
}
But the code doesnt work because JSON object is not recordgnized.
Is there any waY I can broadcast/forward all requests captured that belong to example.com domain?>