Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client.Configure in 4.0.0 version? #810

Closed
vManTech opened this issue Feb 7, 2024 · 8 comments
Closed

client.Configure in 4.0.0 version? #810

vManTech opened this issue Feb 7, 2024 · 8 comments

Comments

@vManTech
Copy link

vManTech commented Feb 7, 2024

How can i convert this my code to Flurl 4.0.x ?

IFlurlClient client = new FlurlClient("https://....");
client.Configure(settings =>
{
settings.HttpClientFactory = new ProxyHttpClientFactory(proxy);
});

Thank you !.

@tmenier
Copy link
Owner

tmenier commented Feb 7, 2024

Please ask on Stack Overflow and I'll be happy to answer. You should include the definition of ProxyHttpClientFactory. I can assume what that might look like, but it's a class defined in your code, not Flurl, so it would be helpful to others to see it. Thanks.

@tmenier tmenier closed this as completed Feb 7, 2024
@alekdavis
Copy link

I have the same question and I suspect I'm not the only one. I did not find it asked at StackOverflow, so I will post a question there, but it would be really helpful to have a sample in the documentation (and, yes, I saw the https://flurl.dev/docs/configuration/?#message-handlers sample, but it's not how we make a call, so need to find out how to transition from the @vManTech's code to v4).

@alekdavis
Copy link

@tmenier
Copy link
Owner

tmenier commented Mar 24, 2024

Answered here. I think the confusion here might be that setting a proxy needs to happen via the new FlurlClientBuilder object now, rather than through FlurlClient directly. This is because in 4.0 the underlying HttpClient is always created/selected up front when a FlurlClient is created. That was a nice simplification and eliminated some quirks that existed in 3.x's lazy approach, but it also meant that once a FlurlClient is created, it's already too late to mess with message handlers.

@alekdavis
Copy link

@tmenier That's simpler than I thought. :-) Thanks a lot.

@alekdavis
Copy link

@tmenier I just tried your suggestion from the Stack Overflow answer and it does not work. The FlurlClientBuilder's Build method returns the IFlurlClient instance, but there are no methods defined on this interface to make HTTP calls other than SendAsync, so you cannot invoke PostJsonAsync, PatchJsonAsync, or other method in the IFlurlClient interface. Would you mind taking another look at this? Thanks.

@tmenier
Copy link
Owner

tmenier commented Apr 12, 2024

You need to call Request() first.

@alekdavis
Copy link

Oh, man, so sorry for being a dummy. Thanks a lot for a quick response.

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

No branches or pull requests

3 participants