-
-
Save MihaZupan/cdb94380322114b50cd17e3b3ca56ea0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var invoker = new HttpMessageInvoker(new SocketsHttpHandler | |
{ | |
UseCookies = false, | |
UseProxy = false, | |
ActivityHeadersPropagator = null, | |
AllowAutoRedirect = false, | |
AutomaticDecompression = System.Net.DecompressionMethods.None, | |
PooledConnectionIdleTimeout = TimeSpan.FromDays(1) | |
}); | |
var uri = new Uri("http://httpbin.org/get"); | |
for (int repeat = 0; repeat < 4; repeat++) | |
{ | |
if (repeat != 0) | |
{ | |
Console.WriteLine("Pausing"); | |
await Task.Delay(1000); | |
} | |
for (int i = 0; i < 10; i++) | |
{ | |
var request = new HttpRequestMessage(HttpMethod.Get, uri); | |
request.Headers.TryAddWithoutValidation("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8"); | |
request.Headers.TryAddWithoutValidation("Accept-Encoding", "gzip, deflate"); | |
request.Headers.TryAddWithoutValidation("Accept-Language", "en-GB,en-US;q=0.9,en;q=0.8,cs;q=0.7"); | |
request.Headers.TryAddWithoutValidation("Cache-Control", "max-age=0"); | |
request.Headers.TryAddWithoutValidation("Connection", "keep-alive"); | |
request.Headers.TryAddWithoutValidation("Host", "httpbin.org"); | |
request.Headers.TryAddWithoutValidation("Upgrade-Insecure-Requests", "1"); | |
request.Headers.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"); | |
using HttpResponseMessage response = await invoker.SendAsync(request, CancellationToken.None); | |
await response.Content.CopyToAsync(Stream.Null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment