You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2019/05/04 10:24:18 UTC
[thrift] branch master updated (65d5f84 -> 27d8387)
This is an automated email from the ASF dual-hosted git repository.
jensg pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git.
from 65d5f84 renamed TClientTransport.cs file to match its class name TTransport.cs Client: netstd Patch: Albert Hives <ah...@hotmail.com>
new 8d554f5 THRIFT-4859 Enables changing 'UserAgent' Client: C# Patch: Park June Chul <pj...@naver.com>
new 27d8387 THRIFT-4860 Allow changing "User-Agent" Client: netstd Patch: Jens Geyer
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
lib/csharp/src/Transport/THttpClient.cs | 15 +++++++++++++--
lib/netstd/Thrift/Transport/Client/THttpTransport.cs | 18 ++++++++++++------
2 files changed, 25 insertions(+), 8 deletions(-)
[thrift] 01/02: THRIFT-4859 Enables changing 'UserAgent' Client: C#
Patch: Park June Chul
Posted by je...@apache.org.
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 <pj...@naver.com>
AuthorDate: Wed Apr 24 10:19:01 2019 +0900
THRIFT-4859 Enables changing 'UserAgent'
Client: C#
Patch: Park June Chul <pj...@naver.com>
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;
[thrift] 02/02: THRIFT-4860 Allow changing "User-Agent" Client:
netstd Patch: Jens Geyer
Posted by je...@apache.org.
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 27d8387c49a49fcf193893f834e9766ae0b051c1
Author: Jens Geyer <je...@apache.org>
AuthorDate: Sat May 4 12:11:52 2019 +0200
THRIFT-4860 Allow changing "User-Agent"
Client: netstd
Patch: Jens Geyer
---
lib/netstd/Thrift/Transport/Client/THttpTransport.cs | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/lib/netstd/Thrift/Transport/Client/THttpTransport.cs b/lib/netstd/Thrift/Transport/Client/THttpTransport.cs
index 0dd5493..627c93d 100644
--- a/lib/netstd/Thrift/Transport/Client/THttpTransport.cs
+++ b/lib/netstd/Thrift/Transport/Client/THttpTransport.cs
@@ -1,4 +1,4 @@
-// Licensed to the Apache Software Foundation(ASF) under one
+// 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
// regarding copyright ownership.The ASF licenses this file
@@ -41,23 +41,29 @@ namespace Thrift.Transport.Client
private bool _isDisposed;
private MemoryStream _outputStream = new MemoryStream();
- public THttpTransport(Uri u, IDictionary<string, string> customHeaders = null)
- : this(u, Enumerable.Empty<X509Certificate>(), customHeaders)
+ public THttpTransport(Uri u, IDictionary<string, string> customHeaders = null, string userAgent = null)
+ : this(u, Enumerable.Empty<X509Certificate>(), customHeaders, userAgent)
{
}
public THttpTransport(Uri u, IEnumerable<X509Certificate> certificates,
- IDictionary<string, string> customHeaders)
+ IDictionary<string, string> customHeaders, string userAgent = null)
{
_uri = u;
_certificates = (certificates ?? Enumerable.Empty<X509Certificate>()).ToArray();
CustomHeaders = customHeaders;
+ if (!string.IsNullOrEmpty(userAgent))
+ UserAgent = userAgent;
+
// due to current bug with performance of Dispose in netcore https://github.com/dotnet/corefx/issues/8809
// this can be switched to default way (create client->use->dispose per flush) later
_httpClient = CreateClient();
}
+ // According to RFC 2616 section 3.8, the "User-Agent" header may not carry a version number
+ public readonly string UserAgent = "Thrift netstd THttpClient";
+
public IDictionary<string, string> CustomHeaders { get; }
public int ConnectTimeout
@@ -149,7 +155,7 @@ namespace Thrift.Transport.Client
}
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-thrift"));
- httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("THttpTransport", "1.0.0"));
+ httpClient.DefaultRequestHeaders.UserAgent.TryParseAdd(UserAgent);
if (CustomHeaders != null)
{
@@ -223,4 +229,4 @@ namespace Thrift.Transport.Client
_isDisposed = true;
}
}
-}
\ No newline at end of file
+}