This is an automated email from the ASF dual-hosted git repository. jensg pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/thrift.git
commit 8d554f503ee8b10e2a225e4e755158e494d40983 Author: Park June Chul <[email protected]> AuthorDate: Wed Apr 24 10:19:01 2019 +0900 THRIFT-4859 Enables changing 'UserAgent' Client: C# Patch: Park June Chul <[email protected]> This closes #1787 --- lib/csharp/src/Transport/THttpClient.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/csharp/src/Transport/THttpClient.cs b/lib/csharp/src/Transport/THttpClient.cs index 667fc25..986799c 100644 --- a/lib/csharp/src/Transport/THttpClient.cs +++ b/lib/csharp/src/Transport/THttpClient.cs @@ -1,4 +1,4 @@ -/** +/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -43,6 +43,7 @@ namespace Thrift.Transport private int readTimeout = 30000; private IDictionary<string, string> customHeaders = new Dictionary<string, string>(); + private string userAgent = "C#/THttpClient"; #if !SILVERLIGHT private IWebProxy proxy = WebRequest.DefaultWebProxy; @@ -52,12 +53,22 @@ namespace Thrift.Transport : this(u, Enumerable.Empty<X509Certificate>()) { } + public THttpClient(Uri u, string userAgent) + : this(u, userAgent, Enumerable.Empty<X509Certificate>()) + { + } public THttpClient(Uri u, IEnumerable<X509Certificate> certificates) { uri = u; this.certificates = (certificates ?? Enumerable.Empty<X509Certificate>()).ToArray(); } + public THttpClient(Uri u, string userAgent, IEnumerable<X509Certificate> certificates) + { + uri = u; + this.userAgent = userAgent; + this.certificates = (certificates ?? Enumerable.Empty<X509Certificate>()).ToArray(); + } public int ConnectTimeout { @@ -271,7 +282,7 @@ namespace Thrift.Transport // Make the request connection.ContentType = "application/x-thrift"; connection.Accept = "application/x-thrift"; - connection.UserAgent = "C#/THttpClient"; + connection.UserAgent = userAgent; connection.Method = "POST"; #if !SILVERLIGHT connection.ProtocolVersion = HttpVersion.Version10;
