Index: indy_http_protocol.pas
===================================================================
--- indy_http_protocol.pas (revision 4555)
+++ indy_http_protocol.pas (working copy)
@@ -56,14 +56,18 @@
FFormat : string;
FConnection : TidHttp;
FCookieManager : ICookieManager;
+ FConnectTimeout, FReadTimeout: Integer;
private
function GetAddress: string;
+ function GetConnectTimeout: Integer;
function GetProtocolVersion : string;
function GetProxyPassword: string;
function GetProxyPort: Integer;
function GetProxyServer: string;
function GetProxyUsername: string;
+ function GetReadTimeOut: Integer;
procedure SetAddress(const AValue: string);
+ procedure SetConnectTimeout(AValue: Integer);
procedure SetProtocolVersion(const AValue : string);
procedure SetProxyPassword(const AValue: string);
procedure SetProxyPort(const AValue: Integer);
@@ -72,7 +76,11 @@
function GetContentType: string;
procedure SetContentType(const Value: string);
function GetSoapAction: string;
+ procedure SetReadTimeout(AValue: Integer);
procedure SetSoapAction(const Value: string);
+{$IFDEF INDY_9}
+ procedure SetReadTimeoutOnConnect(Sender: TObject);
+{$ENDIF}
protected
procedure DoSendAndReceive(ARequest,AResponse:TStream);override;
public
@@ -90,6 +98,8 @@
property SoapAction : string read GetSoapAction write SetSoapAction;
property Format : string read FFormat write FFormat;
property ProtocolVersion : string read GetProtocolVersion write SetProtocolVersion;
+ property ConnectTimeout: Integer read GetConnectTimeout write SetConnectTimeout;
+ property ReadTimeout: Integer read GetReadTimeout write SetReadTimeout;
End;
procedure INDY_RegisterHTTP_Transport();
@@ -126,6 +136,11 @@
Result := FConnection.Request.URL;
end;
+function THTTPTransport.GetConnectTimeout: Integer;
+begin
+ Result := FConnectTimeout;
+end;
+
function THTTPTransport.GetProtocolVersion : string;
begin
Result := ProtocolVersionMAP[FConnection.ProtocolVersion];
@@ -151,11 +166,21 @@
Result := FConnection.ProxyParams.ProxyUsername;
end;
+function THTTPTransport.GetReadTimeOut: Integer;
+begin
+ Result := FReadTimeout;
+end;
+
function THTTPTransport.GetSoapAction: string;
begin
Result := FConnection.Request.CustomHeaders.Values['SOAPAction'];
end;
+procedure THTTPTransport.SetReadTimeout(AValue: Integer);
+begin
+ FReadTimeout := AValue;
+end;
+
function THTTPTransport.GetTransportName() : string;
begin
Result := sTRANSPORT_NAME;
@@ -166,6 +191,11 @@
FConnection.Request.URL := AValue;
end;
+procedure THTTPTransport.SetConnectTimeout(AValue: Integer);
+begin
+ FConnectTimeout := AValue;
+end;
+
procedure THTTPTransport.SetContentType(const Value: string);
begin
FConnection.Request.ContentType := Value;
@@ -207,10 +237,20 @@
FConnection.Request.CustomHeaders.Values['SOAPAction'] := Value;
end;
+{$IFDEF INDY_9}
+procedure THTTPTransport.SetReadTimeoutOnConnect(Sender: TObject);
+begin
+ FConnection.ReadTimeout := FReadTimeout;
+end;
+{$ENDIF}
+
constructor THTTPTransport.Create();
begin
inherited;
FConnection := TidHttp.Create(Nil);
+{$IFDEF INDY_9}
+ FConnection.OnConnected := {$IFDEF FPC}@{$ENDIF}SetReadTimeoutOnConnect;
+{$ENDIF}
end;
destructor THTTPTransport.Destroy();
@@ -227,7 +267,12 @@
then begin
FConnection.ProxyParams.BasicAuthentication := True;
end;
- FConnection.Post(Address,ARequest, AResponse);
+
+{$IFDEF INDY_9}
+ FConnection.ReadTimeout := FConnectTimeout;
+{$ENDIF}
+
+ FConnection.Post(Address, ARequest, AResponse);
end;
function THTTPTransport.GetContentType: string;
Εισαγωγή κώδικα εδώ...