Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 7120248

Browse files
committed
Add more liberal UserAgent
1 parent 717bc65 commit 7120248

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

src/ServiceStack.Text/HttpUtils.HttpClient.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,18 +1065,7 @@ public static HttpRequestMessage WithHeader(this HttpRequestMessage httpReq, str
10651065
}
10661066
else if (name.Equals(HttpHeaders.UserAgent, StringComparison.OrdinalIgnoreCase))
10671067
{
1068-
if (value.IndexOf('/') >= 0)
1069-
{
1070-
var product = value.LastLeftPart('/');
1071-
var version = value.LastRightPart('/');
1072-
httpReq.Headers.UserAgent.Add(new ProductInfoHeaderValue(product, version));
1073-
}
1074-
else
1075-
{
1076-
// Avoid format exceptions
1077-
var commentFmt = value[0] == '(' && value[^1] == ')' ? value : $"({value})";
1078-
httpReq.Headers.UserAgent.Add(new ProductInfoHeaderValue(commentFmt));
1079-
}
1068+
httpReq.Headers.UserAgent.ParseAdd(value);
10801069
}
10811070
else
10821071
{

0 commit comments

Comments
 (0)