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/06/20 23:48:47 UTC

[thrift] branch master updated: THRIFT-4891 Align HTTP test client with all other variants Client: netstd Patch: Jens Geyer

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


The following commit(s) were added to refs/heads/master by this push:
     new 96c6113  THRIFT-4891 Align HTTP test client with all other variants Client: netstd Patch: Jens Geyer
96c6113 is described below

commit 96c6113dda9869b7e2d4318bc0bce4f12f3ca3d2
Author: Jens Geyer <je...@apache.org>
AuthorDate: Fri Jun 14 22:39:56 2019 +0200

    THRIFT-4891 Align HTTP test client with all other variants
    Client: netstd
    Patch: Jens Geyer
    
    This closes #1816
---
 test/netstd/Client/TestClient.cs | 87 +++++++++++++++++++++-------------------
 1 file changed, 46 insertions(+), 41 deletions(-)

diff --git a/test/netstd/Client/TestClient.cs b/test/netstd/Client/TestClient.cs
index ddc36ac..6be1023 100644
--- a/test/netstd/Client/TestClient.cs
+++ b/test/netstd/Client/TestClient.cs
@@ -55,6 +55,7 @@ namespace ThriftTest
     {
         Socket,
         TlsSocket,
+        Http,
         NamedPipe
     }
 
@@ -79,6 +80,7 @@ namespace ThriftTest
                     if (args[i] == "-u")
                     {
                         url = args[++i];
+                        transport = TransportChoice.Http;
                     }
                     else if (args[i] == "-n")
                     {
@@ -151,6 +153,9 @@ namespace ThriftTest
                     case TransportChoice.TlsSocket:
                         Console.WriteLine("Using encrypted transport");
                         break;
+                    case TransportChoice.Http:
+                        Console.WriteLine("Using HTTP transport");
+                        break;
                     case TransportChoice.NamedPipe:
                         Console.WriteLine("Using named pipes transport");
                         break;
@@ -223,55 +228,55 @@ namespace ThriftTest
             
             public TTransport CreateTransport()
             {
-                if (url == null)
+                // endpoint transport
+                TTransport trans = null;
+
+                switch(transport)
                 {
-                    // endpoint transport
-                    TTransport trans = null;
+                    case TransportChoice.Http:
+                        Debug.Assert(url != null);
+                        trans = new THttpTransport(new Uri(url), null);
+                        break;
 
-                    switch(transport)
-                    {
-                        case TransportChoice.NamedPipe:
-                            Debug.Assert(pipe != null);
-                            trans = new TNamedPipeTransport(pipe);
-                            break;
-
-                        case TransportChoice.TlsSocket:
-                           var cert = GetClientCert();
-                            if (cert == null || !cert.HasPrivateKey)
-                            {
-                                throw new InvalidOperationException("Certificate doesn't contain private key");
-                            }
+                    case TransportChoice.NamedPipe:
+                        Debug.Assert(pipe != null);
+                        trans = new TNamedPipeTransport(pipe);
+                        break;
+
+                    case TransportChoice.TlsSocket:
+                        var cert = GetClientCert();
+                        if (cert == null || !cert.HasPrivateKey)
+                        {
+                            throw new InvalidOperationException("Certificate doesn't contain private key");
+                        }
                             
-                            trans = new TTlsSocketTransport(host, port, 0, cert, 
-                                (sender, certificate, chain, errors) => true,
-                                null, SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12);
-                            break;
-
-                        case TransportChoice.Socket:
-                        default:
-                            trans = new TSocketTransport(host, port);
-                            break;
-                    }
+                        trans = new TTlsSocketTransport(host, port, 0, cert, 
+                            (sender, certificate, chain, errors) => true,
+                            null, SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12);
+                        break;
 
+                    case TransportChoice.Socket:
+                    default:
+                        trans = new TSocketTransport(host, port);
+                        break;
+                }
 
-                    // layered transport
-                    switch(layered)
-                    {
-                        case LayeredChoice.Buffered:
-                            trans = new TBufferedTransport(trans);
-                            break;
-                        case LayeredChoice.Framed:
-                            trans = new TFramedTransport(trans);
-                            break;
-                        default:
-                            Debug.Assert(layered == LayeredChoice.None);
-                            break;
-                    }
 
-                    return trans;
+                // layered transport
+                switch(layered)
+                {
+                    case LayeredChoice.Buffered:
+                        trans = new TBufferedTransport(trans);
+                        break;
+                    case LayeredChoice.Framed:
+                        trans = new TFramedTransport(trans);
+                        break;
+                    default:
+                        Debug.Assert(layered == LayeredChoice.None);
+                        break;
                 }
 
-                return new THttpTransport(new Uri(url), null);
+                return trans;
             }
 
             public TProtocol CreateProtocol(TTransport transport)