Comments (7)
How would configure the proxy in the traditional HttpClient
? Are you referring to the MessageHandler
?
from fluentlyhttpclient.
I'm referring to the proxy credentials.
If I would configure at traditional client it would be like at the end of the message.
I wanted to know how can I set credentials and set that by using Fluently.
//Example of traditional Client:
var proxy = new WebProxy
{
Address = new Uri($"http://{proxyHost}:{proxyPort}"),
BypassOnLocal = false,
UseDefaultCredentials = false,
// *** These creds are given to the proxy server, not the web server ***
Credentials = new NetworkCredential(
userName: proxyUserName,
password: proxyPassword)
};
// Now create a client handler which uses that proxy
var httpClientHandler = new HttpClientHandler
{
Proxy = proxy,
};
// Omit this part if you don't need to authenticate with the web server:
if (needServerAuthentication)
{
httpClientHandler.PreAuthenticate = true;
httpClientHandler.UseDefaultCredentials = false;
// *** These creds are given to the web server, not the proxy server ***
httpClientHandler.Credentials = new NetworkCredential(
userName: serverUserName,
password: serverPassword);
}
// Finally, create the HTTP client object
var client = new HttpClient(handler: httpClientHandler, disposeHandler: true);
from fluentlyhttpclient.
Ah yea for the MessageHandler as i suspected
Quite simple
fluentHttpClientBuilder.WithMessageHandler(httpClientHandler)
for a complete example you can see tests such as this https://github.com/sketch7/FluentlyHttpClient/blob/master/test/LoggingHttpMiddlewareTest.cs#L29
from fluentlyhttpclient.
Hi!
I thank you...
But, i just did as you said and it doesn't work, I can't reach the endpoint.
I tested in orginal httpClient and worked fine. When I try to use Fluently it just respond some erros...
When I try to see the Result I got Exception.
Follows the message:
from fluentlyhttpclient.
And that's the exception:
"detail": "One or more errors occurred. (Response status code does not indicate success: 404 ().)",
"innerException": "Response status code does not indicate success: 404 ().",
"innerExceptionInnerExpetion": "",
"targetSite": "GetResultCore"
from fluentlyhttpclient.
Oh, and this link returns 404:
https://github.com/sketch7/FluentlyHttpClient/blob/feature/timer-mw-debuglog/test/LoggingHttpMiddlewareTest.cs#L29
from fluentlyhttpclient.
Opps sorry.. by mistake i linked from a branch - updated https://github.com/sketch7/FluentlyHttpClient/blob/master/test/LoggingHttpMiddlewareTest.cs#L29
Strange, it should work - theres not much adding to it from my end when setting the HttpMessageHandler
If you can either provide me a working example which I can check or at least send me how you're configuring fluently with the message handler maybe I can help
from fluentlyhttpclient.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluentlyhttpclient.