How to customize HttpClientRequester with Default Headers?
See original GitHub issueHow do I add a Header to a configuration using Proxy? Every time I try to add Header, the proxy stops working.
With this code the proxy works:
_handler = new HttpClientHandler() { Proxy = new WebProxy("127.0.0.1", 8888), UseProxy = true, }; _config = Configuration.Default.WithRequesters(_handler).WithJs().WithDefaultLoader().WithDefaultCookies();
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
How to set the Content-Type header for an HttpClient ...
using (var httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri("http://example.com/"); httpClient.DefaultRequestHeaders.Add(" ...
Read more >C# - How to add or remove headers using the HttpClient
You can set default headers on the HttpClient using the DefaultRequestHeaders property: _httpClient.DefaultRequestHeaders.Add( ...
Read more >HttpClient.DefaultRequestHeaders Property
The DefaultRequestHeaders property represents the headers that an app developer can set, not all of the headers that may eventually be sent with...
Read more >Custom HTTP Header with the Apache HttpClient
In this tutorial, we'll look at how to set a custom header with the HttpClient. If you want to dig deeper and learn...
Read more >Add a Custom HTTP Header with the HttpClient
Instead of setting the same headers on every request, we can set default headers that will be added to each request automatically. import...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you really want to change the agent for
HttpClientRequester
I would explicitly use it (with aHttpClient
instance).Hint: if you load AngleSharp.Io anyway, then also use the much better / advanced cookie container from it.
Hope that helps!
@FlorianRappl, again thank you for your time and fast & depth reply.
Using
reliply.org
is very cool thing, thank you for showing it! Doing something would have been my next move. Impossible solve problems without certainties.So now it’s clear, the server (in my case
google.com
) is simply ignoring theAccept-Language
headers. I’m posting same query string by hand with a Chrome setted to en-US and results are different. When I useAngleSharp
I don’t know why but Google understand that the request is made from Italy (where I live).Thanks very much for your help, it was very useful. Beyond that it’s no longer due to AngleSharp (which I’m starting really to love)…
Have a nice day!