I want to set proxy with Username and password for AFNetworking.
Below Is my code:
proxyDict = @{
@"HTTPEnable" : [NSNumber numberWithInt:1],
(NSString *)kCFNetworkProxiesHTTPProxy : proxyHost,
(NSString *)kCFNetworkProxiesHTTPPort : proxyPortFormted,
};
NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
sessionConfiguration.connectionProxyDictionary = proxyDict;
NSMutableURLRequest *mutableRequest = [NSMutableURLRequest requestWithURL:URL];
[mutableRequest addValue:@"header Name" forHTTPHeaderField:@"header Value"];
After Adding this I am getting:
"Request failed: unacceptable content-type: text/html"
For this problem. I add this line.
manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
After Adding the above line. I am getting this error.
"JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.,
But its working correctly
curl --proxy proxyIP:proxyPort -U headerName:headerPassword.
Please help