THRIFT-5012 Centralize configuration aspects into a commonly used configuration object [ci skip]
Client: Delphi
Patch: Jens Geyer
This closes #1955
diff --git a/lib/delphi/src/Thrift.Transport.MsxmlHTTP.pas b/lib/delphi/src/Thrift.Transport.MsxmlHTTP.pas
index b92cce1..bdc65d1 100644
--- a/lib/delphi/src/Thrift.Transport.MsxmlHTTP.pas
+++ b/lib/delphi/src/Thrift.Transport.MsxmlHTTP.pas
@@ -34,13 +34,14 @@
Winapi.ActiveX, Winapi.msxml,
{$ENDIF}
Thrift.Collections,
+ Thrift.Configuration,
Thrift.Transport,
Thrift.Exception,
Thrift.Utils,
Thrift.Stream;
type
- TMsxmlHTTPClientImpl = class( TTransportImpl, IHTTPClient)
+ TMsxmlHTTPClientImpl = class( TEndpointTransportBase, IHTTPClient)
strict private
FUri : string;
FInputStream : IThriftStream;
@@ -59,7 +60,6 @@
function Read( const pBuf : Pointer; const buflen : Integer; off: Integer; len: Integer): Integer; override;
procedure Write( const pBuf : Pointer; off, len : Integer); override;
procedure Flush; override;
- procedure CheckReadBytesAvailable( const value : Integer); override;
procedure SetDnsResolveTimeout(const Value: Integer);
function GetDnsResolveTimeout: Integer;
@@ -81,26 +81,29 @@
property ReadTimeout: Integer read GetReadTimeout write SetReadTimeout;
property CustomHeaders: IThriftDictionary<string,string> read GetCustomHeaders;
public
- constructor Create( const AUri: string; const aTransportCtl : ITransportControl = nil);
+ constructor Create( const aUri: string; const aConfig : IThriftConfiguration); reintroduce;
destructor Destroy; override;
end;
implementation
+const
+ XMLHTTP_CONNECTION_TIMEOUT = 60 * 1000;
+ XMLHTTP_SENDRECV_TIMEOUT = 30 * 1000;
{ TMsxmlHTTPClientImpl }
-constructor TMsxmlHTTPClientImpl.Create(const AUri: string; const aTransportCtl : ITransportControl);
+constructor TMsxmlHTTPClientImpl.Create( const aUri: string; const aConfig : IThriftConfiguration);
begin
- inherited Create( aTransportCtl);
- FUri := AUri;
+ inherited Create( aConfig);
+ FUri := aUri;
// defaults according to MSDN
FDnsResolveTimeout := 0; // no timeout
- FConnectionTimeout := 60 * 1000;
- FSendTimeout := 30 * 1000;
- FReadTimeout := 30 * 1000;
+ FConnectionTimeout := XMLHTTP_CONNECTION_TIMEOUT;
+ FSendTimeout := XMLHTTP_SENDRECV_TIMEOUT;
+ FReadTimeout := XMLHTTP_SENDRECV_TIMEOUT;
FCustomHeaders := TThriftDictionaryImpl<string,string>.Create;
FOutputStream := TThriftStreamAdapterDelphi.Create( TMemoryStream.Create, True);
@@ -219,13 +222,6 @@
end;
end;
-procedure TMsxmlHTTPClientImpl.CheckReadBytesAvailable( const value : Integer);
-begin
- if FInputStream <> nil
- then FInputStream.CheckReadBytesAvailable( value)
- else raise TTransportExceptionNotOpen.Create('No request has been sent');
-end;
-
function TMsxmlHTTPClientImpl.Read( const pBuf : Pointer; const buflen : Integer; off: Integer; len: Integer): Integer;
begin
if FInputStream = nil then begin
@@ -234,7 +230,6 @@
try
Result := FInputStream.Read( pBuf, buflen, off, len);
- ConsumeReadBytes( result);
except
on E: Exception
do raise TTransportExceptionUnknown.Create(E.Message);
@@ -261,6 +256,7 @@
xmlhttp.send( IUnknown( TStreamAdapter.Create( ms, soReference )));
FInputStream := nil;
FInputStream := TThriftStreamAdapterCOM.Create( IUnknown( xmlhttp.responseStream) as IStream);
+ UpdateKnownMessageSize( FInputStream.Size);
finally
ms.Free;
end;