Skip to content

Commit

Permalink
Connection Timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusvicente100 committed Jun 29, 2024
1 parent 5f65b39 commit 440868c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/RESTRequest4D.Request.Contract.pas
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ interface
{$IF DEFINED(RR4D_NETHTTP)}
function Asynchronous(const AValue: Boolean): IRequest;
function SynchronizedEvents(const AValue: Boolean): IRequest;
function ConnectionTimeout(const AConnectiomTimeout: Integer): IRequest;
{$ENDIF}
{$IF DEFINED(RR4D_INDY) or DEFINED(FPC) or DEFINED(RR4D_SYNAPSE) or DEFINED(RR4D_NETHTTP) or DEFINED(RR4D_ICS)}
function AddParam(const AName, AValue: string): IRequest;
Expand Down
9 changes: 8 additions & 1 deletion src/RESTRequest4D.Request.NetHTTP.pas
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ TRequestNetHTTP = class(TInterfacedObject, IRequest)
function Accept(const AAccept: string): IRequest; overload;
function Timeout: Integer; overload;
function Timeout(const ATimeout: Integer): IRequest; overload;
function ConnectionTimeout(const AConnectiomTimeout: Integer): IRequest;
function Adapters(const AAdapter: IRequestAdapter): IRequest; overload;
function Adapters(const AAdapters: TArray<IRequestAdapter>): IRequest; overload;
function Adapters: TArray<IRequestAdapter>; overload;
Expand Down Expand Up @@ -339,6 +340,12 @@ function TRequestNetHTTP.ClearParams: IRequest;
FParams.Clear;
end;

function TRequestNetHTTP.ConnectionTimeout(const AConnectiomTimeout: Integer): IRequest;
begin
Result := Self;
FNetHTTPClient.ConnectionTimeout := AConnectiomTimeout;
end;

function TRequestNetHTTP.ContentType: string;
begin
Result := FNetHTTPClient.CustHeaders.Value['Content-Type'];
Expand All @@ -352,7 +359,7 @@ function TRequestNetHTTP.ContentType(const AContentType: string): IRequest;

constructor TRequestNetHTTP.Create;
begin
FNetHTTPClient := TNetHTTPClient.Create(nil);;
FNetHTTPClient := TNetHTTPClient.Create(nil);
FNetHTTPClient.ResponseTimeout := 900000;
FNetHTTPClient.ConnectionTimeout := 900000;
FNetHTTPClient.UserAgent := 'User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36';
Expand Down

0 comments on commit 440868c

Please sign in to comment.