Yuqing Huang
Yuqing Huang

Reputation: 805

how to set proxy details using AFNetworking

we recently use AFNetworking instead of ASIHttpRequest. But I cannot find any API in AFNetworking to set proxy details for a request as ASIHttpRequest offered. Could anyone give a help? Thanks!

Upvotes: 3

Views: 3610

Answers (1)

Aaron Brager
Aaron Brager

Reputation: 66292

AFNetworking uses NSURLRequest objects for the actual networking.

NSURLRequest does not support configurable HTTP proxies, except that it will of course follow the proxy server set up in your network preferences.

Possible solutions; none ideal:

  1. Instruct your user what proxy to set up in settings
  2. Create your own proxy support using the CFURLConnection classes
  3. Use ASIHTTPRequest

You can also submit an enhancement request to Apple.

If you choose option #2, you might be able to wrap it in an NSOperation subclass and throw it into AFNetworking's operation queue. I'm not sure if that would work though. Either way, you might also be able to get some helpful code from the ASIHTTPRequest code base.


Update for AFNetworking / iOS 7: If you use the *session instead of the *requestoperation interface, you can configure an HTTP Proxy using [NSURLSessionConfiguration -connectionProxyDictionary].

Upvotes: 3

Related Questions