Server Internal Error : Premature end of script headers in file.cgi
I am running Apache server. When I send the request from HTML using ajax call to cgi, I am not getting any response.
I found the following error statement in the httpd/error_lo开发者_开发问答g file: Premature end of script headers: file.cgi
When I gave alert to the status code, it returned 500 Internal Server Error.
How to resolve this?
You're not returning a full set of headers. The output for a CGI must be of the format:
[header]
[blankline]
[body]
If you're getting the "Premature end..." error, the most likely reason is that you're not supplying any header. At an absolute bare minimum, you should return the content-type and then any other optional fields, for example, a simple "Hello world" response would be:
Content-type: text/plain
Hello world!
Or a simple HTML example:
Content-type: text/html
<html>
<body>Hello world!</body>
</html>
Other headers you may want to return with Content-type include those that control the cache, cookies, redirects, etc.
精彩评论