From 4b110912c5c800aa6aae8da81a8965ba51848636 Mon Sep 17 00:00:00 2001 From: Aleksander Wolak Date: Thu, 17 Nov 2022 23:51:02 +0100 Subject: [PATCH] Add User Agent without validation for custom agents not allowed by HttpClient. --- src/RestSharp/RestClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RestSharp/RestClient.cs b/src/RestSharp/RestClient.cs index 5abdba0d1..7202c4fa0 100644 --- a/src/RestSharp/RestClient.cs +++ b/src/RestSharp/RestClient.cs @@ -129,7 +129,7 @@ void ConfigureHttpClient(HttpClient httpClient) { if (Options.MaxTimeout > 0) httpClient.Timeout = TimeSpan.FromMilliseconds(Options.MaxTimeout); if (Options.UserAgent != null && httpClient.DefaultRequestHeaders.UserAgent.All(x => x.Product?.Name != Options.UserAgent)) { - httpClient.DefaultRequestHeaders.UserAgent.ParseAdd(Options.UserAgent); + httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", Options.UserAgent); } if (Options.Expect100Continue != null) httpClient.DefaultRequestHeaders.ExpectContinue = Options.Expect100Continue;