mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 15:55:54 +01:00
Send DocumentIndex if request route = '/' and index file exists
FIX Charset issue on static contents
This commit is contained in:
parent
b760489777
commit
be7d5d7183
@ -309,8 +309,13 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
|
||||||
|
{$IF CompilerVersion > 30}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
AnsiStrings;
|
System.AnsiStrings;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TRESTResponse = class(TInterfacedObject, IRESTResponse)
|
TRESTResponse = class(TInterfacedObject, IRESTResponse)
|
||||||
@ -1258,7 +1263,7 @@ var
|
|||||||
I: Integer;
|
I: Integer;
|
||||||
begin
|
begin
|
||||||
Result := '';
|
Result := '';
|
||||||
for I := Low(AResourceParams) to High(AResourceParams) do
|
for I := low(AResourceParams) to high(AResourceParams) do
|
||||||
Result := Result + '/' + TIdURI.ParamsEncode(AResourceParams[I]);
|
Result := Result + '/' + TIdURI.ParamsEncode(AResourceParams[I]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1396,7 +1401,7 @@ var
|
|||||||
I: Integer;
|
I: Integer;
|
||||||
begin
|
begin
|
||||||
SetLength(FParams, Length(AValues));
|
SetLength(FParams, Length(AValues));
|
||||||
for I := Low(AValues) to High(AValues) do
|
for I := low(AValues) to high(AValues) do
|
||||||
FParams[I] := AValues[I];
|
FParams[I] := AValues[I];
|
||||||
Result := self;
|
Result := self;
|
||||||
end;
|
end;
|
||||||
@ -1490,7 +1495,12 @@ begin
|
|||||||
begin
|
begin
|
||||||
Result.HasError := True;
|
Result.HasError := True;
|
||||||
Result.Body.Write(UTF8Encode(E.ErrorMessage)[1],
|
Result.Body.Write(UTF8Encode(E.ErrorMessage)[1],
|
||||||
AnsiStrings.ElementToCharLen(UTF8Encode(E.ErrorMessage), Length(E.ErrorMessage) * 2));
|
{$IF CompilerVersion > 30}
|
||||||
|
System.AnsiStrings.ElementToCharLen(UTF8Encode(E.ErrorMessage),
|
||||||
|
{$ELSE}
|
||||||
|
ElementToCharLen(UTF8Encode(E.ErrorMessage),
|
||||||
|
{$ENDIF}
|
||||||
|
Length(E.ErrorMessage) * 2));
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise;
|
raise;
|
||||||
@ -1569,7 +1579,12 @@ begin
|
|||||||
except
|
except
|
||||||
on E: EIdHTTPProtocolException do
|
on E: EIdHTTPProtocolException do
|
||||||
Result.Body.Write(UTF8Encode(E.ErrorMessage)[1],
|
Result.Body.Write(UTF8Encode(E.ErrorMessage)[1],
|
||||||
AnsiStrings.ElementToCharLen(UTF8Encode(E.ErrorMessage), Length(E.ErrorMessage) * 2));
|
{$IF CompilerVersion > 30}
|
||||||
|
System.AnsiStrings.ElementToCharLen(UTF8Encode(E.ErrorMessage),
|
||||||
|
{$ELSE}
|
||||||
|
ElementToCharLen(UTF8Encode(E.ErrorMessage),
|
||||||
|
{$ENDIF}
|
||||||
|
Length(E.ErrorMessage) * 2));
|
||||||
else
|
else
|
||||||
raise;
|
raise;
|
||||||
end;
|
end;
|
||||||
|
@ -787,9 +787,15 @@ var
|
|||||||
Config[TMVCConfigKey.IndexDocument]);
|
Config[TMVCConfigKey.IndexDocument]);
|
||||||
if TFile.Exists(lStaticFileName) then
|
if TFile.Exists(lStaticFileName) then
|
||||||
begin
|
begin
|
||||||
if not FMimeTypes.TryGetValue(LowerCase(ExtractFileExt(lStaticFileName)),
|
if FMimeTypes.TryGetValue(LowerCase(ExtractFileExt(lStaticFileName)), lContentType) then
|
||||||
lContentType) then
|
begin
|
||||||
|
lContentType := lContentType + ';charset=' + FMVCConfig
|
||||||
|
[TMVCConfigKey.DefaultContentCharset];
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
lContentType := TMVCMimeType.APPLICATION_OCTETSTREAM;
|
lContentType := TMVCMimeType.APPLICATION_OCTETSTREAM;
|
||||||
|
end;
|
||||||
TMVCStaticContents.SendFile(lStaticFileName, lContentType, lContext);
|
TMVCStaticContents.SendFile(lStaticFileName, lContentType, lContext);
|
||||||
Result := true;
|
Result := true;
|
||||||
end
|
end
|
||||||
@ -925,9 +931,15 @@ begin
|
|||||||
// end
|
// end
|
||||||
// else // serve the file
|
// else // serve the file
|
||||||
// begin
|
// begin
|
||||||
if not FMimeTypes.TryGetValue(LowerCase(ExtractFileExt(lStaticFileName)
|
if FMimeTypes.TryGetValue(LowerCase(ExtractFileExt(lStaticFileName)), lContentType) then
|
||||||
), lContentType) then
|
begin
|
||||||
|
lContentType := lContentType + ';charset=' + FMVCConfig
|
||||||
|
[TMVCConfigKey.DefaultContentCharset];
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
lContentType := TMVCMimeType.APPLICATION_OCTETSTREAM;
|
lContentType := TMVCMimeType.APPLICATION_OCTETSTREAM;
|
||||||
|
end;
|
||||||
TMVCStaticContents.SendFile(lStaticFileName, lContentType, lContext);
|
TMVCStaticContents.SendFile(lStaticFileName, lContentType, lContext);
|
||||||
Result := true;
|
Result := true;
|
||||||
// end;
|
// end;
|
||||||
@ -1064,17 +1076,19 @@ begin
|
|||||||
if Config[TMVCConfigKey.AllowUnhandledAction] = 'false' then
|
if Config[TMVCConfigKey.AllowUnhandledAction] = 'false' then
|
||||||
// tristan
|
// tristan
|
||||||
begin
|
begin
|
||||||
// if not SendDocumentIndexIfPresent then //danieleteti
|
Result := true;
|
||||||
// begin
|
if not SendDocumentIndexIfPresent then // danieleteti
|
||||||
Http404(lContext);
|
begin
|
||||||
Log(TLogLevel.levNormal, Request.Method + ':' +
|
Http404(lContext);
|
||||||
Request.RawPathInfo + ' -> NO ACTION ' + ' - ' +
|
Log(TLogLevel.levNormal, Request.Method + ':' +
|
||||||
IntToStr(Response.StatusCode) + ' ' +
|
Request.RawPathInfo + ' -> NO ACTION ' + ' - ' +
|
||||||
Response.ReasonString);
|
IntToStr(Response.StatusCode) + ' ' +
|
||||||
// end;
|
Response.ReasonString);
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
Result := false;
|
||||||
lContext.Response.FlushOnDestroy := false; // tristan
|
lContext.Response.FlushOnDestroy := false; // tristan
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1850,9 +1864,9 @@ end;
|
|||||||
function TMVCController.GetNewStompClient(ClientID: string): IStompClient;
|
function TMVCController.GetNewStompClient(ClientID: string): IStompClient;
|
||||||
begin
|
begin
|
||||||
raise EMVCException.Create('Not Implemented');
|
raise EMVCException.Create('Not Implemented');
|
||||||
// Result := StompUtils.NewStomp(Config[TMVCConfigKey.StompServer],
|
// Result := StompUtils.NewStomp(Config[TMVCConfigKey.StompServer],
|
||||||
// StrToInt(Config[TMVCConfigKey.StompServerPort]), GetClientID,
|
// StrToInt(Config[TMVCConfigKey.StompServerPort]), GetClientID,
|
||||||
// Config[TMVCConfigKey.StompUsername], Config[TMVCConfigKey.StompPassword]);
|
// Config[TMVCConfigKey.StompUsername], Config[TMVCConfigKey.StompPassword]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMVCController.GetRenderedView(const ViewNames
|
function TMVCController.GetRenderedView(const ViewNames
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<ProjectVersion>18.1</ProjectVersion>
|
<ProjectVersion>18.1</ProjectVersion>
|
||||||
<FrameworkType>VCL</FrameworkType>
|
<FrameworkType>VCL</FrameworkType>
|
||||||
<Base>True</Base>
|
<Base>True</Base>
|
||||||
<Config Condition="'$(Config)'==''">Debug</Config>
|
<Config Condition="'$(Config)'==''">USE_MESSAGING</Config>
|
||||||
<Platform Condition="'$(Platform)'==''">Win32</Platform>
|
<Platform Condition="'$(Platform)'==''">Win32</Platform>
|
||||||
<TargetedPlatforms>1</TargetedPlatforms>
|
<TargetedPlatforms>1</TargetedPlatforms>
|
||||||
<AppType>Console</AppType>
|
<AppType>Console</AppType>
|
||||||
@ -98,7 +98,6 @@
|
|||||||
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
||||||
<Manifest_File>(None)</Manifest_File>
|
<Manifest_File>(None)</Manifest_File>
|
||||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||||
<DCC_RemoteDebug>false</DCC_RemoteDebug>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Cfg_3)'!=''">
|
<PropertyGroup Condition="'$(Cfg_3)'!=''">
|
||||||
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
|
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
|
||||||
@ -230,7 +229,16 @@
|
|||||||
<Overwrite>true</Overwrite>
|
<Overwrite>true</Overwrite>
|
||||||
</Platform>
|
</Platform>
|
||||||
</DeployFile>
|
</DeployFile>
|
||||||
<DeployClass Name="ProjectiOSDeviceResourceRules"/>
|
<DeployClass Name="DependencyModule">
|
||||||
|
<Platform Name="Win32">
|
||||||
|
<Operation>0</Operation>
|
||||||
|
<Extensions>.dll;.bpl</Extensions>
|
||||||
|
</Platform>
|
||||||
|
<Platform Name="OSX32">
|
||||||
|
<Operation>1</Operation>
|
||||||
|
<Extensions>.dylib</Extensions>
|
||||||
|
</Platform>
|
||||||
|
</DeployClass>
|
||||||
<DeployClass Name="ProjectOSXResource">
|
<DeployClass Name="ProjectOSXResource">
|
||||||
<Platform Name="OSX32">
|
<Platform Name="OSX32">
|
||||||
<RemoteDir>Contents\Resources</RemoteDir>
|
<RemoteDir>Contents\Resources</RemoteDir>
|
||||||
@ -544,16 +552,7 @@
|
|||||||
<Operation>1</Operation>
|
<Operation>1</Operation>
|
||||||
</Platform>
|
</Platform>
|
||||||
</DeployClass>
|
</DeployClass>
|
||||||
<DeployClass Name="DependencyModule">
|
<DeployClass Name="ProjectiOSDeviceResourceRules"/>
|
||||||
<Platform Name="Win32">
|
|
||||||
<Operation>0</Operation>
|
|
||||||
<Extensions>.dll;.bpl</Extensions>
|
|
||||||
</Platform>
|
|
||||||
<Platform Name="OSX32">
|
|
||||||
<Operation>1</Operation>
|
|
||||||
<Extensions>.dylib</Extensions>
|
|
||||||
</Platform>
|
|
||||||
</DeployClass>
|
|
||||||
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
|
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
|
||||||
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
|
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
|
||||||
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
|
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user