Browse Source

[httpServer] GetFileMIMEType remove query

Exilon 5 years ago
parent
commit
689bd43cfd
1 changed files with 8 additions and 3 deletions
  1. 8 3
      Quick.HttpServer.Types.pas

+ 8 - 3
Quick.HttpServer.Types.pas

@@ -1,13 +1,13 @@
 { ***************************************************************************
 { ***************************************************************************
 
 
-  Copyright (c) 2016-2019 Kike Pérez
+  Copyright (c) 2016-2020 Kike Pérez
 
 
   Unit        : Quick.HttpServer.Types
   Unit        : Quick.HttpServer.Types
   Description : Http Server Types
   Description : Http Server Types
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.8
   Version     : 1.8
   Created     : 30/08/2019
   Created     : 30/08/2019
-  Modified    : 17/10/2019
+  Modified    : 26/03/2020
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -541,8 +541,13 @@ begin
 end;
 end;
 
 
 function TMIMETypes.GetFileMIMEType(const aFilename: string): string;
 function TMIMETypes.GetFileMIMEType(const aFilename: string): string;
+var
+  fname : string;
 begin
 begin
-  if not fMIMEList.TryGetValue(ExtractFileExt(aFilename),Result) then Result := 'text/html';
+  fname := ExtractFileExt(aFilename);
+  //remove queries
+  if fname.Contains('?') then fname := Copy(fname,1,fname.IndexOf('?'));
+  if not fMIMEList.TryGetValue(fname,Result) then Result := 'text/html';
 end;
 end;
 
 
 { EControlledException }
 { EControlledException }