Skip to content

Commit

Permalink
Updating UserAgent string
Browse files Browse the repository at this point in the history
  • Loading branch information
reverentgeek committed Jul 20, 2015
1 parent dcc16c3 commit 3c96b30
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions LeanKit.API.Client.Library/RestSharpCommandProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Net;
using System.Reflection;
using System.Text;
using System.Threading;
using LeanKit.API.Client.Library.Exceptions;
Expand All @@ -24,12 +25,14 @@ namespace LeanKit.API.Client.Library
{
public class RestSharpCommandProcessor : IRestCommandProcessor
{
private const string LeanKitUserAgent = "LeanKit.API.Client/1.0.8";
private readonly string _leanKitUserAgent = "LeanKit.API.Client";
private readonly IntegrationSettings _settings;
private readonly IValidationService _validationService;

public RestSharpCommandProcessor(IValidationService validationService, IntegrationSettings settings)
{
var version = Assembly.GetExecutingAssembly().GetName().Version;
_leanKitUserAgent += "/" + version;
_validationService = validationService;
_settings = settings;
}
Expand Down Expand Up @@ -78,7 +81,7 @@ public RestSharpCommandProcessor(IValidationService validationService, Integrati
request.Method = "POST";
request.ContentType = contentType;
request.ContentLength = formBytes.Length;
request.UserAgent = LeanKitUserAgent;
request.UserAgent = _leanKitUserAgent;
AddAuth(request, accountAuth);

using (var requestStream = request.GetRequestStream())
Expand Down Expand Up @@ -120,7 +123,7 @@ public AssetFile Download(ILeanKitAccountAuth accountAuth, string resource)
var request = WebRequest.Create(accountAuth.GetAccountUrl() + resource) as HttpWebRequest;

if (request == null) throw new Exception("Error downloading file. Could not create HttpWebRequest");
request.UserAgent = LeanKitUserAgent;
request.UserAgent = _leanKitUserAgent;
AddAuth(request, accountAuth);

var response = request.GetResponse() as HttpWebResponse;
Expand Down Expand Up @@ -195,7 +198,7 @@ private static byte[] GetMultipartFormData(Dictionary<string, object> parameters
{
BaseUrl = new Uri(accountAuth.GetAccountUrl()),
Authenticator = GetAuthenticator(accountAuth),
UserAgent = LeanKitUserAgent
UserAgent = _leanKitUserAgent
};

var response = RetryRequest(request, accountAuth, client);
Expand Down

0 comments on commit 3c96b30

Please sign in to comment.