File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ public class WebAgent : IWebAgent
19
19
/// <summary>
20
20
/// Additional values to append to the default RedditSharp user agent.
21
21
/// </summary>
22
- public static string DefaultUserAgent { get ; set ; }
22
+ public static string DefaultUserAgent { get ; set ; } = "RedditSharp" ;
23
23
24
24
/// <summary>
25
25
/// web protocol "http", "https"
@@ -50,6 +50,11 @@ public class WebAgent : IWebAgent
50
50
/// </summary>
51
51
public string UserAgent { get ; set ; }
52
52
53
+ /// <summary>
54
+ /// Append the library to the end of the User-Agent string. Default is true.
55
+ /// </summary>
56
+ public bool AppendLibraryToUA { get ; set ; } = true ;
57
+
53
58
private static readonly bool IsMono = Type . GetType ( "Mono.Runtime" ) != null ;
54
59
private static bool IsOAuth => RootDomain == "oauth.reddit.com" ;
55
60
@@ -190,7 +195,8 @@ protected virtual HttpRequestMessage CreateRequest(Uri uri, string method)
190
195
191
196
request . Method = new HttpMethod ( method ) ;
192
197
//request.Headers.UserAgent.ParseAdd(UserAgent);
193
- request . Headers . TryAddWithoutValidation ( "User-Agent" , $ "{ UserAgent } - with RedditSharp by meepster23") ;
198
+ var userAgentString = AppendLibraryToUA ? $ "{ UserAgent } - with RedditSharp by meepster23" : UserAgent ;
199
+ request . Headers . TryAddWithoutValidation ( "User-Agent" , userAgentString ) ;
194
200
return request ;
195
201
}
196
202
You can’t perform that action at this time.
0 commit comments