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
|
||||
|
||||
|
||||
{$IF CompilerVersion > 30}
|
||||
|
||||
uses
|
||||
AnsiStrings;
|
||||
System.AnsiStrings;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
type
|
||||
TRESTResponse = class(TInterfacedObject, IRESTResponse)
|
||||
@ -1258,7 +1263,7 @@ var
|
||||
I: Integer;
|
||||
begin
|
||||
Result := '';
|
||||
for I := Low(AResourceParams) to High(AResourceParams) do
|
||||
for I := low(AResourceParams) to high(AResourceParams) do
|
||||
Result := Result + '/' + TIdURI.ParamsEncode(AResourceParams[I]);
|
||||
end;
|
||||
|
||||
@ -1396,7 +1401,7 @@ var
|
||||
I: Integer;
|
||||
begin
|
||||
SetLength(FParams, Length(AValues));
|
||||
for I := Low(AValues) to High(AValues) do
|
||||
for I := low(AValues) to high(AValues) do
|
||||
FParams[I] := AValues[I];
|
||||
Result := self;
|
||||
end;
|
||||
@ -1490,7 +1495,12 @@ begin
|
||||
begin
|
||||
Result.HasError := True;
|
||||
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
|
||||
else
|
||||
raise;
|
||||
@ -1569,7 +1579,12 @@ begin
|
||||
except
|
||||
on E: EIdHTTPProtocolException do
|
||||
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
|
||||
raise;
|
||||
end;
|
||||
|
@ -787,9 +787,15 @@ var
|
||||
Config[TMVCConfigKey.IndexDocument]);
|
||||
if TFile.Exists(lStaticFileName) then
|
||||
begin
|
||||
if not FMimeTypes.TryGetValue(LowerCase(ExtractFileExt(lStaticFileName)),
|
||||
lContentType) then
|
||||
if FMimeTypes.TryGetValue(LowerCase(ExtractFileExt(lStaticFileName)), lContentType) then
|
||||
begin
|
||||
lContentType := lContentType + ';charset=' + FMVCConfig
|
||||
[TMVCConfigKey.DefaultContentCharset];
|
||||
end
|
||||
else
|
||||
begin
|
||||
lContentType := TMVCMimeType.APPLICATION_OCTETSTREAM;
|
||||
end;
|
||||
TMVCStaticContents.SendFile(lStaticFileName, lContentType, lContext);
|
||||
Result := true;
|
||||
end
|
||||
@ -925,9 +931,15 @@ begin
|
||||
// end
|
||||
// else // serve the file
|
||||
// begin
|
||||
if not FMimeTypes.TryGetValue(LowerCase(ExtractFileExt(lStaticFileName)
|
||||
), lContentType) then
|
||||
if FMimeTypes.TryGetValue(LowerCase(ExtractFileExt(lStaticFileName)), lContentType) then
|
||||
begin
|
||||
lContentType := lContentType + ';charset=' + FMVCConfig
|
||||
[TMVCConfigKey.DefaultContentCharset];
|
||||
end
|
||||
else
|
||||
begin
|
||||
lContentType := TMVCMimeType.APPLICATION_OCTETSTREAM;
|
||||
end;
|
||||
TMVCStaticContents.SendFile(lStaticFileName, lContentType, lContext);
|
||||
Result := true;
|
||||
// end;
|
||||
@ -1064,17 +1076,19 @@ begin
|
||||
if Config[TMVCConfigKey.AllowUnhandledAction] = 'false' then
|
||||
// tristan
|
||||
begin
|
||||
// if not SendDocumentIndexIfPresent then //danieleteti
|
||||
// begin
|
||||
Result := true;
|
||||
if not SendDocumentIndexIfPresent then // danieleteti
|
||||
begin
|
||||
Http404(lContext);
|
||||
Log(TLogLevel.levNormal, Request.Method + ':' +
|
||||
Request.RawPathInfo + ' -> NO ACTION ' + ' - ' +
|
||||
IntToStr(Response.StatusCode) + ' ' +
|
||||
Response.ReasonString);
|
||||
// end;
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Result := false;
|
||||
lContext.Response.FlushOnDestroy := false; // tristan
|
||||
end;
|
||||
end;
|
||||
|
@ -4,7 +4,7 @@
|
||||
<ProjectVersion>18.1</ProjectVersion>
|
||||
<FrameworkType>VCL</FrameworkType>
|
||||
<Base>True</Base>
|
||||
<Config Condition="'$(Config)'==''">Debug</Config>
|
||||
<Config Condition="'$(Config)'==''">USE_MESSAGING</Config>
|
||||
<Platform Condition="'$(Platform)'==''">Win32</Platform>
|
||||
<TargetedPlatforms>1</TargetedPlatforms>
|
||||
<AppType>Console</AppType>
|
||||
@ -98,7 +98,6 @@
|
||||
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
||||
<Manifest_File>(None)</Manifest_File>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<DCC_RemoteDebug>false</DCC_RemoteDebug>
|
||||
</PropertyGroup>
|
||||
<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>
|
||||
@ -230,7 +229,16 @@
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</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">
|
||||
<Platform Name="OSX32">
|
||||
<RemoteDir>Contents\Resources</RemoteDir>
|
||||
@ -544,16 +552,7 @@
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<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="ProjectiOSDeviceResourceRules"/>
|
||||
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user