Transforming URLs
To transform URLs, the OnNetworkRequest
-
Identify specific URLs using techniques such as regex or pattern matching.
Note: This first step is optional because you can choose to transform the URLs of all network requests. -
Modify the URL property of the
IHttpRequestTrackerobject. -
Assign a valid URL to the
urlproperty. Modifying other properties of theIHttpRequestTrackerobject will be ignored. -
Return
true.
For example:
public static bool NetworkRequestCallback(IHttpRequestTracker tracker)
{
var maskUrl = new Uri("http://networkrequest-mask.com/");
tracker.Uri = maskUrl;
return true;
}
Transforming Sensitive URLs
You may want to identify and transform URLs that contain sensitive information.
For example:
public static bool NetworkRequestCallback(IHttpRequestTracker tracker)
{
var urlString = tracker.Uri.ToString();
if (urlString.Contains("accountInfo"))
{
tracker.Uri = new Uri("http://customer-account.com/");
}
return true;
}