From ca5a350fd366332b21e8549bcc96e4206e7b6f24 Mon Sep 17 00:00:00 2001 From: abhivijay96 Date: Tue, 17 May 2016 07:36:44 +0530 Subject: [PATCH] Update ServiceClient.cs --- .../Microsoft.Rest.ClientRuntime/ServiceClient.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs index d6ae6d7146e80..78142ca5759bb 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime/ServiceClient.cs @@ -208,8 +208,8 @@ 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 @@ -217,6 +217,10 @@ public bool SetUserAgent(string productName) { if(!_disposed && HttpClient != null) { + /// + /// Dispose the the old useragent. + /// + HttpClient.DefaultRequestHeaders.UserAgent.Clear(); HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName, GetClientVersion())); // returns true if the userAgent was added return true; @@ -231,6 +235,10 @@ public bool SetUserAgent(string productName,string version) { if(!_disposed && HttpClient != null) { + /// + /// Dispose the the old useragent. + /// + HttpClient.DefaultRequestHeaders.UserAgent.Clear(); HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(productName,version); // returns true if the userAgent was added return true;