Network Masking
Last updated
List of keys that will be automatically masked"
"authorization_token, auth_token, auth, access_token, token, oauth_token, bearer_token, refresh_token, jwt_token, jwt, Username, password, pwd, api_key, apikey, secret, client_secret, app_secret, consumer_secret"NetworkLogger.autoMaskingEnabled = falseLCQNetworkLogger.autoMaskingEnabled = false;let path = "/products"
let requestPredicate = NSPredicate(format: "URL.path MATCHES %@", path)
let responsePredicate = NSPredicate(format: "statusCode >= %d AND statusCode <= %d", 200, 399)
NetworkLogger.setNetworkLoggingRequestFilterPredicate(requestPredicate, responseFilterPredicate: responsePredicate)NSString *path = @"/products";
NSPredicate *requestPredicate = [NSPredicate predicateWithFormat:@"URL.path MATCHES %@", path];
NSPredicate *responsePredicate = [NSPredicate predicateWithFormat:@"statusCode >= %d AND statusCode <= %d", 200, 399];
[LCQNetworkLogger setNetworkLoggingRequestFilterPredicate:requestPredicate
responseFilterPredicate:responsePredicate];
// The code above excludes all requests made to URLs that have the /products path.
// It also excludes all responses with success and redirection status codes,
// thus only including requests with 4xx and 5xx responses.NetworkLogger.setRequestObfuscationHandler { (request) -> URLRequest in
var myRequest: NSMutableURLRequest = request as! NSMutableURLRequest
let urlString = request.url?.absoluteString
urlString = obfuscateAuthenticationTokenInString()
let obfuscatedURL = URL(string: urlString)
myRequest.url = obfuscatedURL
return myRequest.copy() as! URLRequest
}
LCQNetworkLogger.requestObfuscationHandler = ^NSURLRequest * _Nonnull(NSURLRequest * _Nonnull request) {
NSMutableURLRequest *myRequest = [request mutableCopy];
NSString *urlString = request.URL.absoluteString;
urlString = [self obfuscateAuthenticationTokenInString:urlString];
NSURL *obfuscatedURL = [NSURL URLWithString:urlString];
myRequest.URL = obfuscatedURL;
return myRequest;
};NetworkLogger.setResponseObfuscationHandler { (data, response, completion) in
if let data = data {
let modifiedData = self.modify(data: data)
let modifiedResponse = self.modify(response: response)
completion(modifiedData, modifiedResponse)
}
}
[LCQNetworkLogger setResponseObfuscationHandler:^(NSData * _Nullable responseData,
NSURLResponse * _Nonnull response,
NetworkObfuscationCompletionBlock _Nonnull returnBlock) {
NSData *modifiedData = [self obfuscateData:responseData];
NSURLResponse *modifiedResponse = [self obfuscateResponse:response];
returnBlock(modifiedData, modifiedResponse);
}];