|Subject:||Re: TIdMimeTable.BuildCache problem|
|Posted by:||Remy Lebeau \(Indy Team\) (email@example.com)|
|Date:||Wed, 30 Sep 2009|
"Farshad Mohajeri" <farshad…@fmsoft.net> wrote in message
> My workaround is to make an explicit call to BuildCache() before
> I activate my HTTP server.
There are a few alternative solitions:
1) change the TIdCustomHTTPServer.InitComponent() method to pass True
instead of False to the AutoFill parameter of TIdMimeTable's constructor.
However, whether you build the cache manually, or have the server do it
automatically, that will not prevent BuildCache() from being called on a
per-file basis in all situations. If you ever serve a file extension that
is not known to the OS at server activation, that would cause
FFileExt.IndexOf() inside of TIdMimeTable.GetFileMIMEType() to return -1,
which will call BuildCache() again.
2) Remove TIdMimeTable from TIdCustomHTTPServer and change ServerFile() to
use the IdGlobalProtocols.GetMIMETypeFromFile() function instead. Not
necessarily the best idea for performance, though, which is probably why
TIdCustomHTTPServer has a reusable TIdMimeTable object to begin with.
3) change the FMIMEList and FFileExt members of TIdMimeTable from
TStringList to TIdThreadSafeStringList. Or better, create a separate
TIdThreadSafeMimeTable type of class instead, since TIdMimeTable is used in
other areas of Indy where thread-safety is not as much an issue (those areas
use IdGlobalProtocols.GetMIMETypeFromFile() instead of TIdMimeTable
> Indy version: 10.2.3
That is a very old verison. The current version is 10.5.7.
Remy Lebeau (TeamB)
TIdMimeTable.BuildCache problem posted by Farshad Mohajeri on Wed, 30 Sep 2009