HTTP Traffic monitoring issue when using MonoTouch, HttpClient and Charles Proxy

前端 未结 1 478
Happy的楠姐
Happy的楠姐 2020-12-18 01:30

I\'m new to HttpClient class and I\'m having issue with monitoring requests using Charles Proxy. Basically what I need is to monitor the requests which are made either from

1条回答
  •  半阙折子戏
    2020-12-18 02:26

    There's many ways to initialize HttpClient. Some ways won't talk with the OS (fully managed) and won't be aware of the iOS proxy settings.

    The best (for iOS) is generally to use the handler that uses CFNetwork, see this blog for more details. Basically it means:

    var client = new HttpClient (CFNetworkHandler ());
    

    Otherwise you'll need to set the HttpClientHandler.Proxy to CFNetwork.GetDefaultProxy. E.g.

    var handler = new HttpClientHandler {
        Proxy = CFNetwork.GetDefaultProxy (),
        UseProxy = true,
    };
    var client = new HttpClient(handler);
    

    0 讨论(0)
提交回复
热议问题