Skip to content
This repository has been archived by the owner on Apr 10, 2018. It is now read-only.

ModernHttpClientFactory integration with version 4.0+ #102

Open
tele-bird opened this issue Dec 19, 2017 · 3 comments
Open

ModernHttpClientFactory integration with version 4.0+ #102

tele-bird opened this issue Dec 19, 2017 · 3 comments

Comments

@tele-bird
Copy link

tele-bird commented Dec 19, 2017

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 ?

@tele-bird tele-bird changed the title ModernHttpClientFactory ModernHttpClientFactory integration with version 4.0+ Dec 19, 2017
@tele-bird
Copy link
Author

tele-bird commented Dec 19, 2017

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;
}

@fubar-coder
Copy link
Contributor

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?

@tele-bird
Copy link
Author

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants