Skip to content

Commit

Permalink
Update ServiceClient.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
abhivijay96 committed May 17, 2016
1 parent 328825f commit ca5a350
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,19 @@ protected void InitializeHttpClient(HttpClientHandler httpClientHandler, params
HttpClient = newClient;
Type type = this.GetType();
//setting userAgentBelow is removed because now the client can set it using SetUserAgent method
/* HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(type.FullName,
GetClientVersion()));*/
HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(type.FullName,
GetClientVersion()));
}

//A mehtod to set user agent
public bool SetUserAgent(string productName)
{
if(!_disposed && HttpClient != null)
{
/// <summary>
/// Dispose the the old useragent.
/// </summary>
HttpClient.DefaultRequestHeaders.UserAgent.Clear();
HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName, GetClientVersion()));
// returns true if the userAgent was added
return true;
Expand All @@ -231,6 +235,10 @@ public bool SetUserAgent(string productName,string version)
{
if(!_disposed && HttpClient != null)
{
/// <summary>
/// Dispose the the old useragent.
/// </summary>
HttpClient.DefaultRequestHeaders.UserAgent.Clear();
HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName,version);
// returns true if the userAgent was added
return true;
Expand Down

0 comments on commit ca5a350

Please sign in to comment.