Skip to content

Commit

Permalink
FIX #334
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed Mar 5, 2020
1 parent f99aa89 commit ac9f3bc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ end;
- Fixed! [issue312](https://github.com/danieleteti/delphimvcframework/issues/312)
- Fixed! [issue334](https://github.com/danieleteti/delphimvcframework/issues/334)
- **Breaking Change!** In `MVCActiveRecord` attribute `MVCPrimaryKey` has been removed and merged with `MVCTableField`, so now `TMVCActiveRecordFieldOption` is a set of `foPrimaryKey`, `foAutoGenerated`, `foTransient` (check `activerecord_showcase.dproj` sample).
- **Breaking Change!** Middleware `OnAfterControllerAction` are now invoked in the same order of `OnBeforeControllerAction` (previously were invoked in reversed order).
Expand Down
9 changes: 7 additions & 2 deletions samples/fileupload/WebModuleUnit1.pas
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,20 @@ TWebModule1 = class(TWebModule)

implementation

uses FileUploadControllerU, MVCFramework.Commons,
MVCFramework.View.Renderers.TemplatePro;
uses
FileUploadControllerU,
MVCFramework.Commons,
MVCFramework.View.Renderers.TemplatePro,
MVCFramework.Middleware.Trace;

{$R *.dfm}


procedure TWebModule1.WebModuleCreate(Sender: TObject);
begin
MVC := TMVCEngine.Create(self);
MVC.AddController(TFileUploadController);
MVC.AddMiddleware(TMVCTraceMiddleware.Create);
MVC.SetViewEngine(TMVCTemplateProViewEngine);
MVC.Config[TMVCConfigKey.ViewPath] := ExtractFilePath(GetModuleName(HInstance)
) + '..\..\templates';
Expand Down
12 changes: 10 additions & 2 deletions sources/MVCFramework.Middleware.Trace.pas
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,22 @@ procedure TMVCTraceMiddleware.OnBeforeControllerAction(Context: TWebContext;
procedure TMVCTraceMiddleware.OnBeforeRouting(Context: TWebContext; var Handled: Boolean);
var
lContentStream: TStringStream;
lContentType: string;
begin
lContentStream := TStringStream.Create;
try
Context.Request.RawWebRequest.ReadTotalContent;
Log.Debug('[REQUEST][URL] ' + Context.Request.RawWebRequest.PathInfo, 'trace');
Log.Debug('[REQUEST][QUERYSTRING] ' + Context.Request.RawWebRequest.QueryFields.DelimitedText, 'trace');
lContentStream.WriteString(EncodingGetString(Context.Request.Headers['content-type'],
Context.Request.RawWebRequest.RawContent));
lContentType := Context.Request.Headers['content-type'].ToLower;
if lContentType.Equals(TMVCMediaType.APPLICATION_JSON) or
lContentType.Equals(TMVCMediaType.APPLICATION_XML) or
lContentType.Equals(TMVCMediaType.APPLICATION_FORM_URLENCODED) or
lContentType.StartsWith('text/') then
begin
lContentStream.WriteString(EncodingGetString(lContentType,
Context.Request.RawWebRequest.RawContent));
end;
Log.Debug('[REQUEST][BODY] ' + lContentStream.DataString, 'trace');
finally
lContentStream.Free;
Expand Down
1 change: 1 addition & 0 deletions unittests/general/Several/LiveServerTestU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ TServerTest = class(TBaseServerTest)
[Test]
procedure TestPostAListOfObjects;
// test authentication/authorization with BasicAuth
[Test]
procedure TestBasicAuth01;
[Test]
procedure TestBasicAuth02;
Expand Down

0 comments on commit ac9f3bc

Please sign in to comment.