MIME TYPES



You can modify the MIME types used by MyServer by modifing the file "MIMEtypes.xml". The following is an example of the .xml file:
<MIMETYPES>
-
    <MIMETYPE>
-
    <MIMETYPE defaultAction="DENY">
<EXT>htm</EXT>
<MIME>text/html</MIME>
<CMD>SEND</CMD>
<ACTION name="Host" value="localhost">ALLOW</ACTION>
<FILTER>gzip</FILTER>
<MANAGER>NONE</MANAGER>
</MIMETYPE>


Each block describes a different MIME type.

<EXT> is the type of file

<MIME> is the Mime type.

<CMD> is the way to send the file to the client.

<ACTION name="Host" value="localhost">ALLOW</ACTION> will allow access to the desired MIME Type if the Host is "localhost". In the line <MIMETYPE defaultAction="DENY"> we tell that our MIME Type will DNY access from any host we don't set in the proper ACTION tag (so, it will have to exist in the configuration). Also, the property
defaultAction is optional (when it's omitted, it's set to "ALLOW"). So, in the above example, HTML files will be accessed only through the hostname "localhost".

The tag <ACTION> is optional, unless you specify "DENY" for your defaultAction in your MIME Type.

<FILTER> defines a filter for that Mime Type. The data will pass through the filter before being sent to the user. In the example above, the data would be sent gzipped to the user. It means Gzip works as a filter in MyServer. you can define Gzip to automatically run for every file based in its size, setting the <GZIP_THRESHOLD>, in myserver.xml file. For obvious reasons, data will be sent gzipped only if the client supports gzip - otherwise he'd receive a lot of wierd characters instead of the site requested.

In general, filters can also be applied to dynamic data - like CGI, ISAPI, FastCGI - but they need to be filters that don't modify the contents of the page to be shown to the user.

<MANAGER> completes the <CMD> command specifying, if necessary for the command, an external application to use.
For example using the RUNCGI command, it will be necessary to specify an external process to execute the CGI command, MANAGER under GNU/Linux will be something like this:
<MANAGER>/usr/bin/php-cgi</MANAGER>
or under Windows:
<MANAGER>c:\php\php-cgi.exe</MANAGER>



The following values for sending the file to the client are valid in the <CMD> section:

  1. SEND - Send the file statically as is.  This command is used for files extensions such as .html and .jpg that don't need any external intervention from the web server.
  2. RUNCGI - Run the CGI script indicated in the path.  It is used for file extensions such as .php and .pl that need to be processed before sending any data to the client.
  3. RUNFASTCGI - Run the Fastcgi script.  This type will need a fastcgi parser downloaded (see the PHP page).  It is also used for file extensions such as .php and .pl
  4. EXECUTEFASTCGI - This also runs the Fastcgi script, but unlike the RUNFASTCGI above, it does not need a server to run the script, instead it acts as a self server.
  5. RUNSCGI Handle a specified mime type with this SCGI server.
  6. EXECUTESCGI Handle the file as a self SCGI process.
  7. RUNMSCGI- Run the MSCGI script. This library is only available for myServer. It is used to build fast and efficient CGIs.
  8. EXECUTE -Treat the file as an executable and send the output to the client. 
  9. SENDLINK - Send the file that is contained in a link.
  10. EXECUTEWINCGI - Send the file as a WinCGI
  11. RUNISAPI - Run the ISAPI script.  
  12. EXECUTEISAPI - Runs the ISAPI script but does not need a server to run. Instead, it acts as a self server.
Most applications are already handled in the .xml file.  If you would like to add a MIME type append the file and use the code as an example.