THRIFT-4841 THTTPTransport relies on activeX component
Client: Delphi
Patch: Jens Geyer
This closes #1778
diff --git a/lib/delphi/test/TestClient.pas b/lib/delphi/test/TestClient.pas
index 7b603a3..55bf92b 100644
--- a/lib/delphi/test/TestClient.pas
+++ b/lib/delphi/test/TestClient.pas
@@ -43,6 +43,8 @@
Thrift.Protocol.JSON,
Thrift.Protocol,
Thrift.Transport.Pipes,
+ Thrift.Transport.WinHTTP,
+ Thrift.Transport.MsxmlHTTP,
Thrift.Transport,
Thrift.Stream,
Thrift.Test,
@@ -115,6 +117,7 @@
procedure InitializeProtocolTransportStack;
procedure ShutdownProtocolTransportStack;
+ function InitializeHttpTransport( const aTimeoutSetting : Integer) : IHTTPClient;
procedure JSONProtocolReadWriteTest;
function PrepareBinaryData( aRandomDist : Boolean; aSize : TTestSize) : TBytes;
@@ -188,7 +191,7 @@
+ ' instead of host and port'#10
+ ' --named-pipe arg Windows Named Pipe (e.g. MyThriftPipe)'#10
+ ' --anon-pipes hRead hWrite Windows Anonymous Pipes pair (handles)'#10
- + ' --transport arg (=sockets) Transport: buffered, framed, http, evhttp'#10
+ + ' --transport arg (=sockets) Transport: buffered, framed, http, winhttp'#10
+ ' --protocol arg (=binary) Protocol: binary, compact, json'#10
+ ' --ssl Encrypted Transport using SSL'#10
+ ' -n [ --testloops ] arg (=1) Number of Tests'#10
@@ -274,14 +277,15 @@
Console.WriteLine('Using anonymous pipes ('+IntToStr(Integer(setup.hAnonRead))+' and '+IntToStr(Integer(setup.hAnonWrite))+')');
end
else if s = '--transport' then begin
- // --transport arg (=sockets) Transport: buffered, framed, http, evhttp
+ // --transport arg (=sockets) Transport: buffered, framed, http, winhttp, evhttp
s := args[i];
Inc( i);
if s = 'buffered' then Include( setup.layered, trns_Buffered)
else if s = 'framed' then Include( setup.layered, trns_Framed)
- else if s = 'http' then setup.endpoint := trns_Http
- else if s = 'evhttp' then setup.endpoint := trns_EvHttp
+ else if s = 'http' then setup.endpoint := trns_MsXmlHttp
+ else if s = 'winhttp' then setup.endpoint := trns_WinHttp
+ else if s = 'evhttp' then setup.endpoint := trns_EvHttp // recognized, but not supported
else InvalidArgs;
end
else if s = '--protocol' then begin
@@ -1315,11 +1319,41 @@
end;
+function TClientThread.InitializeHttpTransport( const aTimeoutSetting : Integer) : IHTTPClient;
+var sUrl : string;
+begin
+ ASSERT( FSetup.endpoint in [trns_MsxmlHttp, trns_WinHttp]);
+
+ if FSetup.useSSL
+ then sUrl := 'https://'
+ else sUrl := 'http://';
+
+ sUrl := sUrl + FSetup.host;
+
+ case FSetup.port of
+ 80 : if FSetup.useSSL then sUrl := sUrl + ':'+ IntToStr(FSetup.port);
+ 443 : if not FSetup.useSSL then sUrl := sUrl + ':'+ IntToStr(FSetup.port);
+ else
+ if FSetup.port > 0 then sUrl := sUrl + ':'+ IntToStr(FSetup.port);
+ end;
+
+ Console.WriteLine('Target URL: '+sUrl);
+ case FSetup.endpoint of
+ trns_MsxmlHttp : result := TMsxmlHTTPClientImpl.Create( sUrl);
+ trns_WinHttp : result := TWinHTTPClientImpl.Create( sUrl);
+ else
+ raise Exception.Create(ENDPOINT_TRANSPORTS[FSetup.endpoint]+' unhandled case');
+ end;
+
+ result.DnsResolveTimeout := aTimeoutSetting;
+ result.ConnectionTimeout := aTimeoutSetting;
+ result.SendTimeout := aTimeoutSetting;
+ result.ReadTimeout := aTimeoutSetting;
+end;
+
+
procedure TClientThread.InitializeProtocolTransportStack;
-var
- streamtrans : IStreamTransport;
- http : IHTTPClient;
- sUrl : string;
+var streamtrans : IStreamTransport;
const
DEBUG_TIMEOUT = 30 * 1000;
RELEASE_TIMEOUT = DEFAULT_THRIFT_TIMEOUT;
@@ -1336,24 +1370,10 @@
FTransport := streamtrans;
end;
- trns_Http: begin
+ trns_MsxmlHttp,
+ trns_WinHttp: begin
Console.WriteLine('Using HTTPClient');
- if FSetup.useSSL
- then sUrl := 'https://'
- else sUrl := 'http://';
- sUrl := sUrl + FSetup.host;
- case FSetup.port of
- 80 : if FSetup.useSSL then sUrl := sUrl + ':'+ IntToStr(FSetup.port);
- 443 : if not FSetup.useSSL then sUrl := sUrl + ':'+ IntToStr(FSetup.port);
- else
- if FSetup.port > 0 then sUrl := sUrl + ':'+ IntToStr(FSetup.port);
- end;
- http := THTTPClientImpl.Create( sUrl);
- http.DnsResolveTimeout := HTTP_TIMEOUTS;
- http.ConnectionTimeout := HTTP_TIMEOUTS;
- http.SendTimeout := HTTP_TIMEOUTS;
- http.ReadTimeout := HTTP_TIMEOUTS;
- FTransport := http;
+ FTransport := InitializeHttpTransport( HTTP_TIMEOUTS);
end;
trns_EvHttp: begin
diff --git a/lib/delphi/test/TestConstants.pas b/lib/delphi/test/TestConstants.pas
index 37969dc..6bb20e9 100644
--- a/lib/delphi/test/TestConstants.pas
+++ b/lib/delphi/test/TestConstants.pas
@@ -39,7 +39,8 @@
TEndpointTransport = (
trns_Sockets,
- trns_Http,
+ trns_MsxmlHttp,
+ trns_WinHttp,
trns_NamedPipes,
trns_AnonPipes,
trns_EvHttp // as listed on http://thrift.apache.org/test
@@ -63,7 +64,7 @@
= ('Buffered', 'Framed');
ENDPOINT_TRANSPORTS : array[TEndpointTransport] of string
- = ('Sockets', 'Http', 'Named Pipes','Anon Pipes', 'EvHttp');
+ = ('Sockets', 'Http', 'WinHttp', 'Named Pipes','Anon Pipes', 'EvHttp');
// defaults are: read=false, write=true
BINARY_STRICT_READ = FALSE;
diff --git a/lib/delphi/test/TestServer.pas b/lib/delphi/test/TestServer.pas
index 69cb175..374472c 100644
--- a/lib/delphi/test/TestServer.pas
+++ b/lib/delphi/test/TestServer.pas
@@ -592,7 +592,8 @@
if s = 'buffered' then Include( layered, trns_Buffered)
else if s = 'framed' then Include( layered, trns_Framed)
- else if s = 'http' then endpoint := trns_Http
+ else if s = 'http' then endpoint := trns_MsxmlHttp
+ else if s = 'winhttp' then endpoint := trns_WinHttp
else if s = 'anonpipe' then endpoint := trns_AnonPipes
else InvalidArgs;
end
@@ -650,8 +651,9 @@
servertrans := TServerSocketImpl.Create( Port, 0, (trns_Buffered in layered));
end;
- trns_Http : begin
- raise Exception.Create(ENDPOINT_TRANSPORTS[endpoint]+' server transport not implemented');
+ trns_MsxmlHttp,
+ trns_WinHttp : begin
+ raise Exception.Create('HTTP server transport not implemented');
end;
trns_NamedPipes : begin
diff --git a/lib/delphi/test/client.dpr b/lib/delphi/test/client.dpr
index 06dbd3d..1d1607d 100644
--- a/lib/delphi/test/client.dpr
+++ b/lib/delphi/test/client.dpr
@@ -31,6 +31,8 @@
Thrift.Socket in '..\src\Thrift.Socket.pas',
Thrift.Exception in '..\src\Thrift.Exception.pas',
Thrift.Transport.Pipes in '..\src\Thrift.Transport.Pipes.pas',
+ Thrift.Transport.WinHTTP in '..\src\Thrift.Transport.WinHTTP.pas',
+ Thrift.Transport.MsxmlHTTP in '..\src\Thrift.Transport.MsxmlHTTP.pas',
Thrift.Protocol in '..\src\Thrift.Protocol.pas',
Thrift.Protocol.JSON in '..\src\Thrift.Protocol.JSON.pas',
Thrift.Protocol.Compact in '..\src\Thrift.Protocol.Compact.pas',
@@ -39,6 +41,7 @@
Thrift.Server in '..\src\Thrift.Server.pas',
Thrift.Stream in '..\src\Thrift.Stream.pas',
Thrift.TypeRegistry in '..\src\Thrift.TypeRegistry.pas',
+ Thrift.WinHTTP in '..\src\Thrift.WinHTTP.pas',
Thrift.Utils in '..\src\Thrift.Utils.pas';
var
diff --git a/lib/delphi/test/multiplexed/Multiplex.Test.Client.dpr b/lib/delphi/test/multiplexed/Multiplex.Test.Client.dpr
index 4278d8f..a57e93a 100644
--- a/lib/delphi/test/multiplexed/Multiplex.Test.Client.dpr
+++ b/lib/delphi/test/multiplexed/Multiplex.Test.Client.dpr
@@ -36,6 +36,7 @@
Thrift.Server in '..\..\src\Thrift.Server.pas',
Thrift.Stream in '..\..\src\Thrift.Stream.pas',
Thrift.TypeRegistry in '..\..\src\Thrift.TypeRegistry.pas',
+ Thrift.WinHTTP in '..\..\src\Thrift.WinHTTP.pas',
Thrift.Utils in '..\..\src\Thrift.Utils.pas';
var
diff --git a/lib/delphi/test/multiplexed/Multiplex.Test.Server.dpr b/lib/delphi/test/multiplexed/Multiplex.Test.Server.dpr
index 120462b..81ed3dd 100644
--- a/lib/delphi/test/multiplexed/Multiplex.Test.Server.dpr
+++ b/lib/delphi/test/multiplexed/Multiplex.Test.Server.dpr
@@ -36,6 +36,7 @@
Thrift.Collections in '..\..\src\Thrift.Collections.pas',
Thrift.Server in '..\..\src\Thrift.Server.pas',
Thrift.Utils in '..\..\src\Thrift.Utils.pas',
+ Thrift.WinHTTP in '..\..\src\Thrift.WinHTTP.pas',
Thrift.TypeRegistry in '..\..\src\Thrift.TypeRegistry.pas',
Thrift.Stream in '..\..\src\Thrift.Stream.pas';
diff --git a/lib/delphi/test/serializer/TestSerializer.dpr b/lib/delphi/test/serializer/TestSerializer.dpr
index 51e22a4..1f5ae8b 100644
--- a/lib/delphi/test/serializer/TestSerializer.dpr
+++ b/lib/delphi/test/serializer/TestSerializer.dpr
@@ -34,6 +34,7 @@
Thrift.Utils in '..\..\src\Thrift.Utils.pas',
Thrift.Serializer in '..\..\src\Thrift.Serializer.pas',
Thrift.Stream in '..\..\src\Thrift.Stream.pas',
+ Thrift.WinHTTP in '..\..\src\Thrift.WinHTTP.pas',
Thrift.TypeRegistry in '..\..\src\Thrift.TypeRegistry.pas',
System_,
DebugProtoTest,
diff --git a/lib/delphi/test/server.dpr b/lib/delphi/test/server.dpr
index b5e48a6..9731dd4 100644
--- a/lib/delphi/test/server.dpr
+++ b/lib/delphi/test/server.dpr
@@ -40,6 +40,7 @@
Thrift.Server in '..\src\Thrift.Server.pas',
Thrift.TypeRegistry in '..\src\Thrift.TypeRegistry.pas',
Thrift.Utils in '..\src\Thrift.Utils.pas',
+ Thrift.WinHTTP in '..\src\Thrift.WinHTTP.pas',
Thrift.Stream in '..\src\Thrift.Stream.pas';
var
diff --git a/lib/delphi/test/skip/skiptest_version1.dpr b/lib/delphi/test/skip/skiptest_version1.dpr
index 803d6bd..0bfe96f 100644
--- a/lib/delphi/test/skip/skiptest_version1.dpr
+++ b/lib/delphi/test/skip/skiptest_version1.dpr
@@ -33,6 +33,7 @@
Thrift.Collections in '..\..\src\Thrift.Collections.pas',
Thrift.Server in '..\..\src\Thrift.Server.pas',
Thrift.Utils in '..\..\src\Thrift.Utils.pas',
+ Thrift.WinHTTP in '..\..\src\Thrift.WinHTTP.pas',
Thrift.TypeRegistry in '..\..\src\Thrift.TypeRegistry.pas',
Thrift.Stream in '..\..\src\Thrift.Stream.pas';
diff --git a/lib/delphi/test/skip/skiptest_version2.dpr b/lib/delphi/test/skip/skiptest_version2.dpr
index 633b247..7893748 100644
--- a/lib/delphi/test/skip/skiptest_version2.dpr
+++ b/lib/delphi/test/skip/skiptest_version2.dpr
@@ -33,6 +33,7 @@
Thrift.Collections in '..\..\src\Thrift.Collections.pas',
Thrift.Server in '..\..\src\Thrift.Server.pas',
Thrift.Utils in '..\..\src\Thrift.Utils.pas',
+ Thrift.WinHTTP in '..\..\src\Thrift.WinHTTP.pas',
Thrift.TypeRegistry in '..\..\src\Thrift.TypeRegistry.pas',
Thrift.Stream in '..\..\src\Thrift.Stream.pas';
diff --git a/lib/delphi/test/typeregistry/TestTypeRegistry.dpr b/lib/delphi/test/typeregistry/TestTypeRegistry.dpr
index 18a7c7d..fd5e3dd 100644
--- a/lib/delphi/test/typeregistry/TestTypeRegistry.dpr
+++ b/lib/delphi/test/typeregistry/TestTypeRegistry.dpr
@@ -34,6 +34,7 @@
Thrift.Utils in '..\..\src\Thrift.Utils.pas',
Thrift.Serializer in '..\..\src\Thrift.Serializer.pas',
Thrift.Stream in '..\..\src\Thrift.Stream.pas',
+ Thrift.WinHTTP in '..\..\src\Thrift.WinHTTP.pas',
Thrift.TypeRegistry in '..\..\src\Thrift.TypeRegistry.pas',
DebugProtoTest;