NetTalk Central

Author Topic: Mime Types  (Read 3141 times)

Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Mime Types
« on: September 22, 2014, 08:11:44 AM »
Hi Bruce,
We want to replace a IIS server with a NetTalk server. On the IIS server, we are serving files with a unique file extension to our clients where our application process the file on the user’s machine.  On the IIS server, we set the MIME type for the extension of these files to "application/octlet-stream" which tells the browser to execute an app for this file type, similar as PDF reader displays a PDF file.  Likewise I will need to change the "Content-Type" of the Response Header for this type of file in the NetTalk web server. Where is the best place to do this? Should I check every file sent in the _sendfile webhander method for the our file extension and how do I then set the “Content-Type” in the Response Header for this file? Or is there a better method?

Thanks
Rob

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Mime Types
« Reply #1 on: September 22, 2014, 10:12:30 PM »
Hi Robert,

I assume you are serving the files using a simple link - ie something the user clicks on with an href that points to the file?

Also I presume you are able to identify the file type from the name or path?

If so, there is a method in WebHandler (the parent method is in nethttp.clw) called _GetContentType.
It takes a name as a parameter, and from that name you return a string containing the content type.

Note that the filename can include any parameters passed, so if you are basing your code on the extension, you need to strip the parameters off first. A quick look in nethttp.clw will give you the idea.

So you can add code to WebHandler, before the parent call, to add in custom types.

Cheers
Bruce

Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Mime Types
« Reply #2 on: September 23, 2014, 11:55:46 AM »
Hi Bruce,
Your assumptions were correct and with the added code in the web handler, the content type is now what we need  for our files.
Thank-you,
Rob