THRIFT-4891 Align HTTP test client with all other variants
Client: netstd
Patch: Jens Geyer
This closes #1816
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 @@
{
Socket,
TlsSocket,
+ Http,
NamedPipe
}
@@ -79,6 +80,7 @@
if (args[i] == "-u")
{
url = args[++i];
+ transport = TransportChoice.Http;
}
else if (args[i] == "-n")
{
@@ -151,6 +153,9 @@
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 @@
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.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.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;
+ 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;
+ case TransportChoice.Socket:
+ default:
+ trans = new TSocketTransport(host, port);
+ break;
}
- return new THttpTransport(new Uri(url), null);
+
+ // 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;
}
public TProtocol CreateProtocol(TTransport transport)