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 7, 2016
1 parent 0142862 commit 8a2fd9a
Showing 1 changed file with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,38 @@ protected void InitializeHttpClient(HttpClientHandler httpClientHandler, params
FirstMessageHandler = currentHandler;
HttpClient = newClient;
Type type = this.GetType();
HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(type.FullName,
//setting userAgentBelow is removed because now the client can set it using SetUserAgent method
/* HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(type.FullName,
GetClientVersion()));*/
}

//A mehtod to set user agent
public bool SetUserAgent(string produtName)
{
if(!_disposed && HttpClient != null)
{
HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName,
GetClientVersion()));
// returns true if the userAgent was added
return true;
}
// returns false if the httpclient was disposed before invoking the method
return false;
}

//Another method to setuseragent and it's version

public bool SetUserAgent(string produtName,string version)
{
if(!_disposed && HttpClient != null)
{
HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName,version);
// returns true if the userAgent was added
return true;
}
// returns false if the httpclient was disposed before invoking the method
return false;
}

/// <summary>
/// Gets the AssemblyInformationalVersion if available
/// if not it gets the AssemblyFileVerion
Expand Down

0 comments on commit 8a2fd9a

Please sign in to comment.