rubyTrials

A way to keep track of breakthroughs I've made in Ruby and Ruby on Rails.

My Photo
Name:
Location: Cadillac, Michigan, United States

Wednesday, February 16, 2005

Premature end of script headers

Here's my first ruby trial post. The trial today, Ruby based cgi and the annoying header problem with apache.

First the sample script:


#!/usr/bin/ruby -w

### ruServe ####################################################################
# @Author:Michael Christenson II
# @Date:2005-01-30 21:00:00 EST
# @Email: michael@xystus.info
################################################################################

# List Constants
PRODUCT="ruServe"
PRODUCT_VERSION="0.0.1"
HTTP_HEADER="Content-type: text\/html\n\n"
###

# List Glabal Variables
###

# Start ruServe
###
puts "#{HTTP_HEADER}"+
"<html>"+
"<head><title>Request - #{PRODUCT} ver. #{PRODUCT_VERSION}</title></head>"+
"<body>"+
"<p>stillworking</p>"+
"</body>"+
"</html>"

Now the really painful part was getting the header to work. I kept getting error 500 from the web server, and kept dancing around my server, through logs and such, trying to find the answer.

The problem: Malformed header and premature end of script headers
The answer: take out the extra \r's for the Microsoft compatibility if you are on a unix server.

Old header: Content-type: text\/html\n\r\n\r
New header: Content-type: text\/html\n\n

Simple and works fine. Until the next trial, please keep yourself together, I'll have an answer eventually ;).

0 Comments:

Post a Comment

<< Home