When an attachment URL such as
is INCLUDE'd, TWiki retrieves the attachment directly rather than issuing an HTTP request to itself.
But that shortcut works only for
Attachment files of other extensions result in HTTP requests to itself.
This behavior is not optimal.
A better behavior
INCLUDE is supposed to:
- Handle all attachment URLs on the TWiki site directly regardless of file name extension
- Determine MIME type of an attachment based on file name extension in the same manner as the
viewfile script and behave accordingly
- Observe the
allowanytype parameter even when it retrieves an attachment directly
File name extension to MIME type conversion takes place in
For INCLUDE to behave consistently with the
script regarding file name extension to MIME type correspondence, that function needs to be used by INCLUDE.
should change in the following two aspects.
TWiki::UI::View::_suffixToMimeType() is a local function of
TWiki::UI::View and not supposed be called from
TWiki::_includeUrl(). As such,
TWiki::UI::View::_suffixToMimeType() should be moved to
TWiki::UI::View::_suffixToMimeType() takes two arguments:
$fileName. There is no need for
$session to determine MIME type. So
TWiki::suffixToMimeType() takes one argument,