Why do I get malformed header errors when using a MATLAB Compiler-generated standalone application as a CGI application with Apache?

6 次查看(过去 30 天)
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

采纳的回答

MathWorks Support Team
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 个)

类别

Help CenterFile Exchange 中查找有关 Workspace Variables and MAT Files 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by