mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 15:55:54 +01:00
This commit is contained in:
parent
b1f838ece9
commit
4a25c05811
@ -1488,6 +1488,8 @@ The current beta release is named 3.2.3-radium-beta. If you want to stay on the-
|
|||||||
#### Bug Fix in 3.2.3-radium-beta
|
#### Bug Fix in 3.2.3-radium-beta
|
||||||
- Fixed a rendering problem in swagger interface format in case of specific JSON structure
|
- Fixed a rendering problem in swagger interface format in case of specific JSON structure
|
||||||
- Fix [issue 594](https://github.com/danieleteti/delphimvcframework/issues/594) (Thanks to [biware-repo](https://github.com/biware-repo))
|
- Fix [issue 594](https://github.com/danieleteti/delphimvcframework/issues/594) (Thanks to [biware-repo](https://github.com/biware-repo))
|
||||||
|
- Fix [issue 595](https://github.com/danieleteti/delphimvcframework/issues/595)
|
||||||
|
- Fix [issue 590](https://github.com/danieleteti/delphimvcframework/issues/590)
|
||||||
|
|
||||||
|
|
||||||
## Trainings, consultancy or custom development service
|
## Trainings, consultancy or custom development service
|
||||||
|
@ -40,7 +40,8 @@ uses
|
|||||||
System.Rtti,
|
System.Rtti,
|
||||||
System.Generics.Collections,
|
System.Generics.Collections,
|
||||||
MVCFramework.Serializer.Commons,
|
MVCFramework.Serializer.Commons,
|
||||||
MVCFramework.Serializer.JsonDataObjects, System.SysUtils;
|
MVCFramework.Serializer.JsonDataObjects,
|
||||||
|
System.SysUtils;
|
||||||
|
|
||||||
const
|
const
|
||||||
JSONRPC_VERSION = '2.0';
|
JSONRPC_VERSION = '2.0';
|
||||||
@ -459,6 +460,11 @@ type
|
|||||||
|
|
||||||
TJSONRPCProxyGeneratorClass = class of TJSONRPCProxyGenerator;
|
TJSONRPCProxyGeneratorClass = class of TJSONRPCProxyGenerator;
|
||||||
|
|
||||||
|
TJSONUtilsHelper = record helper for TJSONUtils
|
||||||
|
class function JSONObjectToRecord<T: record >(const JSONRPCResponse: IInterface): T; overload; static;
|
||||||
|
class function JSONArrayToArrayOfRecord<T: record >(const JSONRPCResponse: IInterface): TArray<T>; overload; static;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure RegisterJSONRPCProxyGenerator(const aLanguage: string; const aClass: TJSONRPCProxyGeneratorClass);
|
procedure RegisterJSONRPCProxyGenerator(const aLanguage: string; const aClass: TJSONRPCProxyGeneratorClass);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -2813,6 +2819,38 @@ begin
|
|||||||
fErrMessage := ErrMessage;
|
fErrMessage := ErrMessage;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TJSONUtilsHelper }
|
||||||
|
|
||||||
|
class function TJSONUtilsHelper.JSONArrayToArrayOfRecord<T>(
|
||||||
|
const JSONRPCResponse: IInterface): TArray<T>;
|
||||||
|
var
|
||||||
|
lIntf: IJSONRPCResponse;
|
||||||
|
begin
|
||||||
|
if Supports(JSONRPCResponse, IJSONRPCResponse, lIntf) then
|
||||||
|
begin
|
||||||
|
Result := TJSONUtils.JSONArrayToArrayOfRecord<T>(lIntf.ResultAsJSONArray);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
RaiseSerializationError('Parameter doesn''t support IJSONRPCResponse');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TJSONUtilsHelper.JSONObjectToRecord<T>(
|
||||||
|
const JSONRPCResponse: IInterface): T;
|
||||||
|
var
|
||||||
|
lIntf: IJSONRPCResponse;
|
||||||
|
begin
|
||||||
|
if Supports(JSONRPCResponse, IJSONRPCResponse, lIntf) then
|
||||||
|
begin
|
||||||
|
Result := TJSONUtils.JSONObjectToRecord<T>(lIntf.ResultAsJSONObject);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
RaiseSerializationError('Parameter doesn''t support IJSONRPCResponse');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
|
||||||
finalization
|
finalization
|
||||||
|
@ -240,9 +240,7 @@ type
|
|||||||
public
|
public
|
||||||
// records
|
// records
|
||||||
class function JSONObjectToRecord<T: record >(const JSONObject: TJsonObject): T; overload; static;
|
class function JSONObjectToRecord<T: record >(const JSONObject: TJsonObject): T; overload; static;
|
||||||
class function JSONObjectToRecord<T: record >(const JSONRPCResponse: IInterface): T; overload; static;
|
|
||||||
class function JSONArrayToArrayOfRecord<T: record >(const JSONArray: TJsonArray): TArray<T>; overload; static;
|
class function JSONArrayToArrayOfRecord<T: record >(const JSONArray: TJsonArray): TArray<T>; overload; static;
|
||||||
class function JSONArrayToArrayOfRecord<T: record >(const JSONRPCResponse: IInterface): TArray<T>; overload; static;
|
|
||||||
// objects
|
// objects
|
||||||
class function JsonObjectToObject<T: class, constructor>(const JSONObject: TJsonObject): T; overload; static;
|
class function JsonObjectToObject<T: class, constructor>(const JSONObject: TJsonObject): T; overload; static;
|
||||||
class function JSONArrayToListOf<T: class, constructor>(const JSONArray: TJsonArray): TObjectList<T>;
|
class function JSONArrayToListOf<T: class, constructor>(const JSONArray: TJsonArray): TObjectList<T>;
|
||||||
@ -266,7 +264,6 @@ implementation
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
MVCFramework.Serializer.JsonDataObjects.CustomTypes,
|
MVCFramework.Serializer.JsonDataObjects.CustomTypes,
|
||||||
MVCFramework.JSONRPC,
|
|
||||||
MVCFramework.Logger,
|
MVCFramework.Logger,
|
||||||
MVCFramework.DataSet.Utils,
|
MVCFramework.DataSet.Utils,
|
||||||
MVCFramework.Nullables;
|
MVCFramework.Nullables;
|
||||||
@ -3951,20 +3948,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TJSONUtils.JSONArrayToArrayOfRecord<T>(const JSONRPCResponse: IInterface): TArray<T>;
|
|
||||||
var
|
|
||||||
lIntf: IJSONRPCResponse;
|
|
||||||
begin
|
|
||||||
if Supports(JSONRPCResponse, IJSONRPCResponse, lIntf) then
|
|
||||||
begin
|
|
||||||
Result := TJSONUtils.JSONArrayToArrayOfRecord<T>(lIntf.ResultAsJSONArray);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
RaiseSerializationError('Parameter doesn''t support IJSONRPCResponse');
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TJSONUtils.JSONArrayToListOf<T>(const JSONArray: TJsonArray): TObjectList<T>;
|
class function TJSONUtils.JSONArrayToListOf<T>(const JSONArray: TJsonArray): TObjectList<T>;
|
||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
@ -4006,20 +3989,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TJSONUtils.JSONObjectToRecord<T>(const JSONRPCResponse: IInterface): T;
|
|
||||||
var
|
|
||||||
lIntf: IJSONRPCResponse;
|
|
||||||
begin
|
|
||||||
if Supports(JSONRPCResponse, IJSONRPCResponse, lIntf) then
|
|
||||||
begin
|
|
||||||
Result := TJSONUtils.JSONObjectToRecord<T>(lIntf.ResultAsJSONObject);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
RaiseSerializationError('Parameter doesn''t support IJSONRPCResponse');
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TJSONUtils.JSONObjectToRecord<T>(const JSONObject: TJsonObject): T;
|
class function TJSONUtils.JSONObjectToRecord<T>(const JSONObject: TJsonObject): T;
|
||||||
var
|
var
|
||||||
lSer: TMVCJsonDataObjectsSerializer;
|
lSer: TMVCJsonDataObjectsSerializer;
|
||||||
|
@ -57,7 +57,7 @@ uses
|
|||||||
MVCFramework.ApplicationSession,
|
MVCFramework.ApplicationSession,
|
||||||
MVCFramework.Serializer.Intf,
|
MVCFramework.Serializer.Intf,
|
||||||
|
|
||||||
{$IFDEF WEBAPACHEHTTP}
|
{$IF Defined(WEBAPACHEHTTP)}
|
||||||
Web.ApacheHTTP,
|
Web.ApacheHTTP,
|
||||||
// Apache Support since XE6 http://docwiki.embarcadero.com/Libraries/XE6/de/Web.ApacheHTTP
|
// Apache Support since XE6 http://docwiki.embarcadero.com/Libraries/XE6/de/Web.ApacheHTTP
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ uses
|
|||||||
// Delphi XE4 (all update) and XE5 (with no update) don't contains this unit. Look for the bug in QC
|
// Delphi XE4 (all update) and XE5 (with no update) don't contains this unit. Look for the bug in QC
|
||||||
// https://quality.embarcadero.com/browse/RSP-17216
|
// https://quality.embarcadero.com/browse/RSP-17216
|
||||||
|
|
||||||
{$IFNDEF MOBILE} // file upload is not supported on mobile
|
{$IF NOT Defined(MOBILE)} // file upload is not supported on mobile
|
||||||
{$IF Defined(SeattleOrBetter)}
|
{$IF Defined(SeattleOrBetter)}
|
||||||
Web.ReqMulti,
|
Web.ReqMulti,
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
@ -75,14 +75,13 @@ uses
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Web.HTTPApp,
|
Web.HTTPApp,
|
||||||
|
|
||||||
{$IFDEF MSWINDOWS}
|
{$IF Defined(MSWINDOWS)}
|
||||||
Web.Win.IsapiHTTP,
|
Web.Win.IsapiHTTP,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Web.WebReq,
|
Web.WebReq,
|
||||||
LoggerPro,
|
LoggerPro,
|
||||||
IdGlobal,
|
IdGlobal,
|
||||||
IdGlobalProtocols,
|
IdGlobalProtocols,
|
||||||
// IdHTTPWebBrokerBridge,
|
|
||||||
Swag.Doc,
|
Swag.Doc,
|
||||||
Swag.Common.Types,
|
Swag.Common.Types,
|
||||||
MVCFramework.Commons,
|
MVCFramework.Commons,
|
||||||
@ -425,7 +424,7 @@ type
|
|||||||
property Files: TAbstractWebRequestFiles read GetFiles;
|
property Files: TAbstractWebRequestFiles read GetFiles;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF WEBAPACHEHTTP}
|
{$IF Defined(WEBAPACHEHTTP)}
|
||||||
|
|
||||||
TMVCApacheWebRequest = class(TMVCWebRequest)
|
TMVCApacheWebRequest = class(TMVCWebRequest)
|
||||||
private
|
private
|
||||||
@ -1301,7 +1300,7 @@ begin
|
|||||||
lEncoding := TEncoding.GetEncoding(lCurrCharset);
|
lEncoding := TEncoding.GetEncoding(lCurrCharset);
|
||||||
try
|
try
|
||||||
|
|
||||||
{$IFDEF BERLINORBETTER}
|
{$IF Defined(BERLINORBETTER)}
|
||||||
FWebRequest.ReadTotalContent; // Otherwise ISAPI Raises "Empty BODY"
|
FWebRequest.ReadTotalContent; // Otherwise ISAPI Raises "Empty BODY"
|
||||||
FBody := lEncoding.GetString(FWebRequest.RawContent);
|
FBody := lEncoding.GetString(FWebRequest.RawContent);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
@ -1977,20 +1976,20 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
{$IFDEF WEBAPACHEHTTP}
|
{$IF Defined(WEBAPACHEHTTP)}
|
||||||
if ARequest.ClassType = TApacheRequest then
|
if ARequest.ClassType = TApacheRequest then
|
||||||
begin
|
begin
|
||||||
FRequest := TMVCApacheWebRequest.Create(ARequest, ASerializers)
|
FRequest := TMVCApacheWebRequest.Create(ARequest, ASerializers)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
{$IFNDEF LINUX}
|
{$IF Defined(MSWINDOWS)}
|
||||||
if ARequest.ClassType = TISAPIRequest then
|
if ARequest.ClassType = TISAPIRequest then
|
||||||
begin
|
begin
|
||||||
FRequest := TMVCISAPIWebRequest.Create(ARequest, ASerializers)
|
FRequest := TMVCISAPIWebRequest.Create(ARequest, ASerializers)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
{$ENDIF}
|
{$ENDIF} //MSWINDOWS
|
||||||
{$ENDIF}
|
{$ENDIF} //WEBAPACHEHTTP
|
||||||
begin
|
begin
|
||||||
FRequest := TMVCIndyWebRequest.Create(ARequest, ASerializers);
|
FRequest := TMVCIndyWebRequest.Create(ARequest, ASerializers);
|
||||||
end;
|
end;
|
||||||
@ -2044,13 +2043,13 @@ end;
|
|||||||
|
|
||||||
function TWebContext.GetHostingFrameworkType: TMVCHostingFrameworkType;
|
function TWebContext.GetHostingFrameworkType: TMVCHostingFrameworkType;
|
||||||
begin
|
begin
|
||||||
{$IFDEF WEBAPACHEHTTP}
|
{$IF Defined(WEBAPACHEHTTP)}
|
||||||
if FRequest.ClassType = TApacheRequest then
|
if FRequest.ClassType = TApacheRequest then
|
||||||
begin
|
begin
|
||||||
Exit(hftApache);
|
Exit(hftApache);
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF MSWINDOWS}
|
{$IF Defined(MSWINDOWS)}
|
||||||
if FRequest.ClassType = TISAPIRequest then
|
if FRequest.ClassType = TISAPIRequest then
|
||||||
begin
|
begin
|
||||||
Exit(hftISAPI);
|
Exit(hftISAPI);
|
||||||
@ -2091,13 +2090,6 @@ begin
|
|||||||
FMessage := AMessage;
|
FMessage := AMessage;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TMVCIndyWebRequest }
|
|
||||||
|
|
||||||
// function TMVCIndyWebRequest.RawHeaders: TStrings;
|
|
||||||
// begin
|
|
||||||
// Result := TMVCHackHTTPAppRequest(FWebRequest).GetHeaders;
|
|
||||||
// end;
|
|
||||||
|
|
||||||
function TWebContext.GetLoggedUser: TUser;
|
function TWebContext.GetLoggedUser: TUser;
|
||||||
begin
|
begin
|
||||||
if not Assigned(FLoggedUser) then
|
if not Assigned(FLoggedUser) then
|
||||||
@ -2197,7 +2189,6 @@ begin
|
|||||||
begin
|
begin
|
||||||
raise EMVCSessionExpiredException.Create('Session not started');
|
raise EMVCSessionExpiredException.Create('Session not started');
|
||||||
end;
|
end;
|
||||||
//SId := TMVCEngine.ExtractSessionIdFromWebRequest(FRequest.RawWebRequest);
|
|
||||||
GlobalSessionList.Remove(SId);
|
GlobalSessionList.Remove(SId);
|
||||||
if SId <> '' then
|
if SId <> '' then
|
||||||
begin
|
begin
|
||||||
@ -2416,7 +2407,7 @@ begin
|
|||||||
[(FConfigCache_MaxRequestSize div 1024)]);
|
[(FConfigCache_MaxRequestSize div 1024)]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF BERLINORBETTER}
|
{$IF Defined(BERLINORBETTER)}
|
||||||
ARequest.ReadTotalContent;
|
ARequest.ReadTotalContent;
|
||||||
|
|
||||||
// Double check for malicious content-length header
|
// Double check for malicious content-length header
|
||||||
|
Loading…
Reference in New Issue
Block a user