Skip to content

Commit 28b5478

Browse files
authored
Add User Agent without validation for custom agents not allowed by HttpClient. (#1973)
1 parent 11bbfc3 commit 28b5478

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/RestSharp/RestClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void ConfigureHttpClient(HttpClient httpClient) {
129129
if (Options.MaxTimeout > 0) httpClient.Timeout = TimeSpan.FromMilliseconds(Options.MaxTimeout);
130130

131131
if (Options.UserAgent != null && httpClient.DefaultRequestHeaders.UserAgent.All(x => x.Product?.Name != Options.UserAgent)) {
132-
httpClient.DefaultRequestHeaders.UserAgent.ParseAdd(Options.UserAgent);
132+
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", Options.UserAgent);
133133
}
134134

135135
if (Options.Expect100Continue != null) httpClient.DefaultRequestHeaders.ExpectContinue = Options.Expect100Continue;

0 commit comments

Comments
 (0)