1

I have an apache server that I am using for cgi. I am writing my cgis in Python.

As long as my responses are of the form "Content-Type: text/html\n #" it works.

But if I send anything else, I get a 500 error and my logs say "malformed header from script. Bad header" Can I change my configurations to make it work? Is there anything else I can do?

2 Answers 2

4

As with all CGI, you need a blank line between the headers and the body.

print 'Content-Type: text/plain'
print
print 'Hello, World!'
Sign up to request clarification or add additional context in comments.

1 Comment

Wow! That was it. I can't believe that was all it was.
1

You need to send a Content-Type header to tell the browser what type of data you're sending it. Without that you'll get the 500 error you're experiencing.

1 Comment

This is true. I tried sending a Content-Type, but it didn't work due to the fact that I didn't add a space line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.