I have a simple CGI script that is working now in production that returns a json object, and so it returns a content type of application/x-javascript. In internet explorer, this file is asked to be downloaded, but i can successfully download it.
the cgi script is perl, and output simple json object
#!/bin/perl print "Cache-control: no-cache\n"; print "Content-type: application/x-javascript\n\n" ; print "var whatever = { .. data here .. }"; We are migrating to new servers, and I believe that that apache is set up similarly in both locations.
The problem is, IE now does not successfully download this file. i get this error:
--------------------------- Windows Internet Explorer --------------------------- Internet Explorer cannot download hero.cgi from lpdww554.trcw.us.aexp.com. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later. --------------------------- OK --------------------------- In debugging, i have tried text/plain, text/html and application/javascript to no avail. when using text, the output shows up properly in IE, but will not execute the javascript in the browser.
This script works in Firefox, and it works on my old server in IE (it downloads the file, does not show in browser). I can't figure out why it's not working on my new server, and i'm sure it's a HTTP header issue. I've posted my headers below.
IE New Script Headers
GET /path/script.cgi HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* Accept-Language: en-us UA-CPU: x86 Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; InfoPath.2; MS-RTC LM 8) Host: newserver.company.com:1091 Connection: Keep-Alive Cookie: (cookie) HTTP/1.1 200 OK Date: Thu, 18 Aug 2011 18:42:56 GMT Server: IBM_HTTP_Server Cache-control: no-cache Expires: 0 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: application/x-javascript IE - Old Script Headers
GET /path/script.cgi HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* Accept-Language: en-us UA-CPU: x86 Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; InfoPath.2; MS-RTC LM 8) Host: oldserver.company.com Connection: Keep-Alive Cookie: cookie HTTP/1.1 200 OK Server: IBM_HTTP_Server Content-Type: application/x-javascript Date: Thu, 18 Aug 2011 18:43:39 GMT Connection: keep-alive Cache-Control: no-cache Cache-Control: max-age=86400 Expires: Fri, 19 Aug 2011 18:43:38 GMT