Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciussanchez committed Jun 19, 2024
1 parent e5594be commit 5f65b39
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/RESTRequest4D.Request.Client.pas
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ constructor TRequestClient.Create;
FRESTRequest.SynchronizedEvents := False;
FParams := TStringList.Create;
FHeaders := TStringList.Create;
FResponse := TResponseClient.Create(FRESTResponse);
FRESTRequest.OnAfterExecute := DoAfterExecute;
FRESTRequest.OnHTTPProtocolError := DoHTTPProtocolError;
DoJoinComponents;
Expand All @@ -336,6 +335,7 @@ function TRequestClient.DeactivateProxy: IRequest;

function TRequestClient.Delete: IResponse;
begin
FResponse := TResponseClient.Create(FRESTResponse);
Result := FResponse;
DoBeforeExecute(FRESTRequest);
FRESTRequest.Method := TRESTRequestMethod.rmDELETE;
Expand Down Expand Up @@ -403,6 +403,7 @@ procedure TRequestClient.ExecuteRequest;

function TRequestClient.Get: IResponse;
begin
FResponse := TResponseClient.Create(FRESTResponse);
Result := FResponse;
DoBeforeExecute(FRESTRequest);
FRESTRequest.Method := TRESTRequestMethod.rmGET;
Expand Down Expand Up @@ -491,6 +492,7 @@ function TRequestClient.Timeout: Integer;

function TRequestClient.Patch: IResponse;
begin
FResponse := TResponseClient.Create(FRESTResponse);
Result := FResponse;
DoBeforeExecute(FRESTRequest);
FRESTRequest.Method := TRESTRequestMethod.rmPATCH;
Expand All @@ -499,6 +501,7 @@ function TRequestClient.Patch: IResponse;

function TRequestClient.Post: IResponse;
begin
FResponse := TResponseClient.Create(FRESTResponse);
Result := FResponse;
DoBeforeExecute(FRESTRequest);
FRESTRequest.Method := TRESTRequestMethod.rmPOST;
Expand Down Expand Up @@ -536,6 +539,7 @@ function TRequestClient.Proxy(const AServer, APassword, AUsername: string; const

function TRequestClient.Put: IResponse;
begin
FResponse := TResponseClient.Create(FRESTResponse);
Result := FResponse;
DoBeforeExecute(FRESTRequest);
FRESTRequest.Method := TRESTRequestMethod.rmPUT;
Expand Down
6 changes: 5 additions & 1 deletion src/RESTRequest4D.Request.FPHTTPClient.pas
Original file line number Diff line number Diff line change
Expand Up @@ -329,30 +329,35 @@ function TRequestFPHTTPClient.OnAfterExecute(const AOnAfterExecute: TRR4DCallbac

function TRequestFPHTTPClient.Get: IResponse;
begin
FResponse := TResponseFpHTTPClient.Create(FFPHTTPClient);
Result := FResponse;
ExecuteRequest(mrGET);
end;

function TRequestFPHTTPClient.Post: IResponse;
begin
FResponse := TResponseFpHTTPClient.Create(FFPHTTPClient);
Result := FResponse;
ExecuteRequest(mrPOST);
end;

function TRequestFPHTTPClient.Put: IResponse;
begin
FResponse := TResponseFpHTTPClient.Create(FFPHTTPClient);
Result := FResponse;
ExecuteRequest(mrPUT);
end;

function TRequestFPHTTPClient.Delete: IResponse;
begin
FResponse := TResponseFpHTTPClient.Create(FFPHTTPClient);
Result := FResponse;
ExecuteRequest(mrDELETE);
end;

function TRequestFPHTTPClient.Patch: IResponse;
begin
FResponse := TResponseFpHTTPClient.Create(FFPHTTPClient);
Result := FResponse;
ExecuteRequest(mrPATCH);
end;
Expand Down Expand Up @@ -641,7 +646,6 @@ constructor TRequestFPHTTPClient.Create;
FFPHTTPClient.ResponseHeaders.Clear;

FHeaders := TstringList.Create;
FResponse := TResponseFpHTTPClient.Create(FFPHTTPClient);
FParams := TstringList.Create;
FFields := TDictionary<string, string>.Create;;
FUrlSegments := TstringList.Create;
Expand Down
6 changes: 5 additions & 1 deletion src/RESTRequest4D.Request.ICS.pas
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,21 @@ function TRequestICS.RaiseExceptionOn500(const ARaiseException: Boolean): IReque

function TRequestICS.Patch: IResponse;
begin
FResponse := TResponseICS.Create(FSslHttpRest);
Result := FResponse;
ExecuteRequest(mrPATCH);
end;

function TRequestICS.Put: IResponse;
begin
FResponse := TResponseICS.Create(FSslHttpRest);
Result := FResponse;
ExecuteRequest(mrPUT);
end;

function TRequestICS.Post: IResponse;
begin
FResponse := TResponseICS.Create(FSslHttpRest);
Result := FResponse;
ExecuteRequest(mrPOST);
end;
Expand All @@ -189,6 +192,7 @@ function TRequestICS.Proxy(const AServer, APassword, AUsername: string; const AP

function TRequestICS.Get: IResponse;
begin
FResponse := TResponseICS.Create(FSslHttpRest);
Result := FResponse;
ExecuteRequest(mrGET);
end;
Expand All @@ -209,6 +213,7 @@ function TRequestICS.DeactivateProxy: IRequest;

function TRequestICS.Delete: IResponse;
begin
FResponse := TResponseICS.Create(FSslHttpRest);
Result := FResponse;
ExecuteRequest(mrDELETE);
end;
Expand Down Expand Up @@ -427,7 +432,6 @@ constructor TRequestICS.Create;
FBodyRaw := TStringList.Create;
FUrlSegments := TStringList.Create;
FBodyRaw.LineBreak := '';
FResponse := TResponseICS.Create(FSslHttpRest);
end;

destructor TRequestICS.Destroy;
Expand Down
6 changes: 5 additions & 1 deletion src/RESTRequest4D.Request.Indy.pas
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,21 @@ procedure TRequestIndy.ExecuteRequest(const AMethod: TMethodRequest);

function TRequestIndy.Patch: IResponse;
begin
FResponse := TResponseIndy.Create(FIdHTTP);
Result := FResponse;
ExecuteRequest(mrPATCH);
end;

function TRequestIndy.Put: IResponse;
begin
FResponse := TResponseIndy.Create(FIdHTTP);
Result := FResponse;
ExecuteRequest(mrPUT);
end;

function TRequestIndy.Post: IResponse;
begin
FResponse := TResponseIndy.Create(FIdHTTP);
Result := FResponse;
ExecuteRequest(mrPOST);
end;
Expand All @@ -313,6 +316,7 @@ function TRequestIndy.Proxy(const AServer, APassword, AUsername: string; const A

function TRequestIndy.Get: IResponse;
begin
FResponse := TResponseIndy.Create(FIdHTTP);
Result := FResponse;
ExecuteRequest(mrGET);
end;
Expand Down Expand Up @@ -346,6 +350,7 @@ function TRequestIndy.KeyFile(const APath: string): IRequest;

function TRequestIndy.Delete: IResponse;
begin
FResponse := TResponseIndy.Create(FIdHTTP);
Result := FResponse;
ExecuteRequest(mrDELETE);
end;
Expand Down Expand Up @@ -629,7 +634,6 @@ constructor TRequestIndy.Create;
FIdSSLIOHandlerSocketOpenSSL.OnStatusInfoEx := Self.OnStatusInfoEx;

FHeaders := TStringList.Create;
FResponse := TResponseIndy.Create(FIdHTTP);
FParams := TStringList.Create;
FUrlSegments := TStringList.Create;

Expand Down
6 changes: 5 additions & 1 deletion src/RESTRequest4D.Request.Synapse.pas
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ function TRequestSynapse.OnAfterExecute(const AOnAfterExecute: TRR4DCallbackOnAf

function TRequestSynapse.Get: IResponse;
begin
FResponse := TResponseSynapse.Create(FHTTPSend);
Result := FResponse;
ExecuteRequest(mrGET);
end;
Expand All @@ -354,24 +355,28 @@ function TRequestSynapse.KeyFile(const APath: string): IRequest;

function TRequestSynapse.Post: IResponse;
begin
FResponse := TResponseSynapse.Create(FHTTPSend);
Result := FResponse;
ExecuteRequest(mrPOST);
end;

function TRequestSynapse.Put: IResponse;
begin
FResponse := TResponseSynapse.Create(FHTTPSend);
Result := FResponse;
ExecuteRequest(mrPUT);
end;

function TRequestSynapse.Delete: IResponse;
begin
FResponse := TResponseSynapse.Create(FHTTPSend);
Result := FResponse;
ExecuteRequest(mrDELETE);
end;

function TRequestSynapse.Patch: IResponse;
begin
FResponse := TResponseSynapse.Create(FHTTPSend);
Result := FResponse;
ExecuteRequest(mrPATCH);
end;
Expand Down Expand Up @@ -704,7 +709,6 @@ constructor TRequestSynapse.Create;
FHTTPSend.Headers.NameValueSeparator := ':';

FHeaders := TstringList.Create;
FResponse := TResponseSynapse.Create(FHTTPSend);
FParams := TstringList.Create;
FFields := TDictionary<string, string>.Create;;
FUrlSegments := TstringList.Create;
Expand Down
5 changes: 5 additions & 0 deletions src/RESTRequest4D.Response.NetHTTP.pas
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ procedure TResponseNetHTTP.SetContent(const AContent: TStringStream);

procedure TResponseNetHTTP.SetHTTPResponse(const AHTTPResponse: IHTTPResponse);
begin
if Assigned(FJSONValue) then
begin
FJSONValue.Free;
FJSONValue := nil;
end;
FHTTPResponse := AHTTPResponse;
end;

Expand Down

0 comments on commit 5f65b39

Please sign in to comment.