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/12 20:17:00 UTC
[thrift] branch master updated: THRIFT-4886 More detailed error
information for WinHTTP transport Client: Delphi 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 19fdca8 THRIFT-4886 More detailed error information for WinHTTP transport Client: Delphi Patch: Jens Geyer
19fdca8 is described below
commit 19fdca82c2e61bd42f92a502a91a07b9dc74b5d2
Author: Jens Geyer <je...@apache.org>
AuthorDate: Wed Jun 12 22:09:05 2019 +0200
THRIFT-4886 More detailed error information for WinHTTP transport
Client: Delphi
Patch: Jens Geyer
---
lib/delphi/src/Thrift.Transport.WinHTTP.pas | 49 +++++++++++++++++++----------
1 file changed, 32 insertions(+), 17 deletions(-)
diff --git a/lib/delphi/src/Thrift.Transport.WinHTTP.pas b/lib/delphi/src/Thrift.Transport.WinHTTP.pas
index 48b74a6..d7eefa8 100644
--- a/lib/delphi/src/Thrift.Transport.WinHTTP.pas
+++ b/lib/delphi/src/Thrift.Transport.WinHTTP.pas
@@ -51,7 +51,10 @@ type
function CreateRequest: IWinHTTPRequest;
function SecureProtocolsAsWinHTTPFlags : Cardinal;
- private type
+ private
+ type
+ TErrorInfo = ( SplitUrl, WinHTTPSession, WinHTTPConnection, WinHTTPRequest, RequestSetup, AutoProxy );
+
THTTPResponseStream = class( TThriftStreamImpl)
private
FRequest : IWinHTTPRequest;
@@ -131,33 +134,45 @@ end;
function TWinHTTPClientImpl.CreateRequest: IWinHTTPRequest;
var
- pair : TPair<string,string>;
+ pair : TPair<string,string>;
session : IWinHTTPSession;
connect : IWinHTTPConnection;
url : IWinHTTPUrl;
sPath : string;
+ info : TErrorInfo;
begin
- url := TWinHTTPUrlImpl.Create( FUri);
+ info := TErrorInfo.SplitUrl;
+ try
+ url := TWinHTTPUrlImpl.Create( FUri);
- session := TWinHTTPSessionImpl.Create('Apache Thrift Delphi WinHTTP');
- session.EnableSecureProtocols( SecureProtocolsAsWinHTTPFlags);
+ info := TErrorInfo.WinHTTPSession;
+ session := TWinHTTPSessionImpl.Create('Apache Thrift Delphi WinHTTP');
+ session.EnableSecureProtocols( SecureProtocolsAsWinHTTPFlags);
- connect := session.Connect( url.HostName, url.Port);
+ info := TErrorInfo.WinHTTPConnection;
+ connect := session.Connect( url.HostName, url.Port);
- sPath := url.UrlPath + url.ExtraInfo;
- result := connect.OpenRequest( (url.Scheme = 'https'), 'POST', sPath, THRIFT_MIMETYPE);
+ info := TErrorInfo.WinHTTPRequest;
+ sPath := url.UrlPath + url.ExtraInfo;
+ result := connect.OpenRequest( (url.Scheme = 'https'), 'POST', sPath, THRIFT_MIMETYPE);
- // setting a timeout value to 0 (zero) means "no timeout" for that setting
- result.SetTimeouts( DnsResolveTimeout, ConnectionTimeout, SendTimeout, ReadTimeout);
+ // setting a timeout value to 0 (zero) means "no timeout" for that setting
+ info := TErrorInfo.RequestSetup;
+ result.SetTimeouts( DnsResolveTimeout, ConnectionTimeout, SendTimeout, ReadTimeout);
- // headers
- result.AddRequestHeader( 'Content-Type: '+THRIFT_MIMETYPE, WINHTTP_ADDREQ_FLAG_ADD);
- for pair in FCustomHeaders do begin
- Result.AddRequestHeader( pair.Key +': '+ pair.Value, WINHTTP_ADDREQ_FLAG_ADD);
- end;
+ // headers
+ result.AddRequestHeader( 'Content-Type: '+THRIFT_MIMETYPE, WINHTTP_ADDREQ_FLAG_ADD);
+ for pair in FCustomHeaders do begin
+ Result.AddRequestHeader( pair.Key +': '+ pair.Value, WINHTTP_ADDREQ_FLAG_ADD);
+ end;
- // AutoProxy support
- result.TryAutoProxy( FUri);
+ // AutoProxy support
+ info := TErrorInfo.AutoProxy;
+ result.TryAutoProxy( FUri);
+ except
+ on e:TException do raise;
+ on e:Exception do raise TTransportExceptionUnknown.Create( e.Message+' (at '+EnumUtils<TErrorInfo>.ToString(Ord(info))+')');
+ end;
end;