Skip to content

Commit

Permalink
Added HEAD and OPTIONS methods to TMVCRestClient. Fix #455
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoduarte19 committed Dec 16, 2020
1 parent d883f87 commit dd8e11a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sources/MVCFramework.RESTClient.Intf.pas
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,18 @@ interface
function Get(const aResource: string): IMVCRESTResponse; overload;
function Get: IMVCRESTResponse; overload;

/// <summary>
/// Execute a Head request.
/// </summary>
function Head(const aResource: string): IMVCRESTResponse; overload;
function Head: IMVCRESTResponse; overload;

/// <summary>
/// Execute a Options request.
/// </summary>
function Options(const aResource: string): IMVCRESTResponse; overload;
function Options: IMVCRESTResponse; overload;

/// <summary>
/// Execute a Post request.
/// </summary>
Expand Down
34 changes: 34 additions & 0 deletions sources/MVCFramework.RESTClient.pas
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,18 @@ TMVCRESTClient = class(TInterfacedObject, IMVCRESTClient)
function Get(const aResource: string): IMVCRESTResponse; overload;
function Get: IMVCRESTResponse; overload;

/// <summary>
/// Execute a Head request.
/// </summary>
function Head(const aResource: string): IMVCRESTResponse; overload;
function Head: IMVCRESTResponse; overload;

/// <summary>
/// Execute a Options request.
/// </summary>
function Options(const aResource: string): IMVCRESTResponse; overload;
function Options: IMVCRESTResponse; overload;

/// <summary>
/// Execute a Post request.
/// </summary>
Expand Down Expand Up @@ -1215,6 +1227,17 @@ function TMVCRESTClient.HandleRedirects: Boolean;
Result := fHTTPClient.HandleRedirects;
end;

function TMVCRESTClient.Head: IMVCRESTResponse;
begin
Result := ExecuteRequest(TMVCHTTPMethodType.httpHEAD);
end;

function TMVCRESTClient.Head(const aResource: string): IMVCRESTResponse;
begin
Resource(aResource);
Result := Head;
end;

function TMVCRESTClient.HeaderValue(const aName: string): string;
var
lParam: TMVCRESTParam;
Expand Down Expand Up @@ -1303,6 +1326,17 @@ function TMVCRESTClient.ObjectIsList(aObject: TObject): Boolean;
Result := fRttiContext.GetType(aObject.ClassType).GetMethod('GetEnumerator') <> nil;
end;

function TMVCRESTClient.Options: IMVCRESTResponse;
begin
Result := ExecuteRequest(TMVCHTTPMethodType.httpOPTIONS);
end;

function TMVCRESTClient.Options(const aResource: string): IMVCRESTResponse;
begin
Resource(aResource);
Result := Options;
end;

procedure TMVCRESTClient.DoValidateServerCertificate(const aSender: TObject; const aRequest: TURLRequest;
const aCertificate: TCertificate; var aAccepted: Boolean);
begin
Expand Down

0 comments on commit dd8e11a

Please sign in to comment.