ModernHttpClientFactory integration with version 4.0+
In order to squeeze the best performance from our Xamarin Android/iOS app, we override DefaultHttpClientFactory.CreateMessageHandler(), as described in issue #34. It works great for us!
However, with our upgrade to version 4.0.8 of FubarCoder.RestSharp.Portable.HttpClient, the DefaultHttpClientFactory.CreateMessageHandler() method no longer exists with both parameters --the IRestRequest has been removed. I also notice that GetProxy(), GetCookies() methods and RequestProxyWrapper class no longer exist. So, there have been some fairly substantial changes to this library...
Can anyone provide guidance around how to modify the integration suggested in #34 to comply with the new interfaces available in version 4.0.8 ?
Here's what I have, but it neglects the proxy and cookies, which are now unavailable from the IRestClient and IRestRequest under the latest interface definition. How to support these?
protected override HttpMessageHandler CreateMessageHandler(IRestClient client)
{
var cookies = client.CookieContainer;
var credentials = client.Credentials;
var httpClientHandler = _nativeMessageHandler.GetINativeMessageHandler();
if (cookies != null)
{
httpClientHandler.UseCookies = true;
httpClientHandler.CookieContainer = cookies;
}
if (credentials != null)
{
httpClientHandler.Credentials = credentials;
}
return httpClientHandler;
}
The main problem with IWebProxy was, that it wasn't available for some target frameworks. I'll convert the project.json stuff to the new csproj format, remove the PCL stuff and add more platforms supporting IWebProxy. This will be released as version 5.0. Is this sufficient for you?
if these DefaultHttpClientFactory methods will be present in version 5.0 (as they were in version 3.x), then yes:
var proxy = GetProxy(client);
var cookies = GetCookies(client, request);
Thank you!