I need to do a simple GET request to a website and parse the response.
I was planning to use the following simple code
var httpClient =_httpClientFactory.CreateClient();
var initialRequest = await httpClient.GetAsync(_config.WebsiteUrl, cancellationToken);
However, the site was poorly made and sends an invalid header in its response, namely "X=Frame-Options", resulting in the following exception.
System.Net.Http.HttpRequestException: Received an invalid header name: 'X=Frame-Options'.
Unfortunately, I do not control the site and it is very unlikely that this issue will be fixed anytime soon. So a workaround is needed.
My idea is to create a local "Man in the middle", so to speak, that would intercept the response sent from the site before reaching my code, remove the offending header, then pass the response on.
I am unfamiliar with networking in C# and I was wondering if there are any good libraries or existing examples for this use case.
I have tried using the Flurl library, but unfortunately, it uses httpclient in its implementation so the exception is still thrown.
Or am I missing something obvious and there is some way to disable the header validation that throws the above exception?