Why do I get malformed header errors when using a MATLAB Compiler-generated standalone application as a CGI application with Apache?
6 views (last 30 days)
Show older comments
I have created a standalone executable, mycgimagic.exe, with MATLAB Compiler which is being called by my web server as a CGI application. In the program I am using DISP to print out the formatted HTML.
When I use this application with Microsoft's Internet Information Services (IIS) web server it works fine. However when it is used with Apache Web Server 2.2, I receive an Internal Server Error and the following message is in the Apache log file
malformed header from script. Bad header= : mycgimagic.exe
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
This error is caused by the automatic formatting done by the DISP command. Apache seems to be more particular about the formatting of the content-type headers in the HTML file than IIS.
To work around this issue, replace every occurrence of the DISP command with PRINTF. For example the command
disp('Content-type: text/html');
should be replaced with
fprintf(1,'Content-type: text/html\n');
After making these changes, the same program should work for both web servers.
0 Comments
More Answers (0)
See Also
Categories
Find more on Workspace Variables and MAT Files in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!