rails app output being display as text/plain

#1
This is what's happening, we have site in the middle of development. The developer is running mongrel on his computer. He then put it up on the staging server which running Litespeed with lsapi. The rails app is working, but litespeed is serving up the wrong header or something. Here is the beginning what I see on the web browser.
--------------------------------------------------------------------
Content-Type: text/html; charset=utf-8
Set-Cookie: _eqnow_session_id=1e1bacd9b11a17b7831f6447538fb1a6; path=/
Status: 200 OK
Cache-Control: no-cache
Content-Length: 7489

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
.
.
.
---------------------------------------------------------------------
Yes, I see the content-type in the browsers, Firefox and IE. When select "view page info" in Firefox, It said Type: text/plain, encoding: ISO-8859-1.

When I telnet into port 80 of the same server and did GET for the same page, I don't see anything about Content-Type being text/plain. Below is what I got from the telnet session.
----------------
GET /product_news HTTP/1.1
host: eqnow.myhost.net

HTTP/1.1 404 Not Found
Content-Length: 7666
Date: Mon, 15 Oct 2007 06:05:19 GMT
Server: LiteSpeed
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100

Content-Type: text/html; charset=utf-8
Set-Cookie: _eqnow_session_id=447c8d24db39ea3aa6e33810d7c6729a; path=/
Status: 200 OK
Cache-Control: no-cache
Content-Length: 7489

So what's causing my web browsers to think it's plain text and not rendering the html?
 
#2
Well I was wrong about the cache thing.

I found out that my developer had stop litespeed on the staging server and he was running mongrel on it.

When I stop mongrel and started litespeed, I am still getting the error from the above message.
 
Last edited:

mistwang

LiteSpeed Staff
#3
I think there might be some output to Ruby processes' STDOUT before the first response header was sent. So, the response header was treated as part of the response body.
 
#4
But when I use telnet to GET the page that has the problem, I don't see anything extra. I will clarify the telnet session, the first two lines are what I typed in, after the empty line is what the litespeed send back.

GET /product_news HTTP/1.1
host: eqnow.myhost.net

HTTP/1.1 404 Not Found
Content-Length: 7666
Date: Mon, 15 Oct 2007 06:05:19 GMT
Server: LiteSpeed
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100

Content-Type: text/html; charset=utf-8
Set-Cookie: _eqnow_session_id=447c8d24db39ea3aa6e33810d7c6729a ; path=/
Status: 200 OK
Cache-Control: no-cache
Content-Length: 7489
.
.
.
 
#5
OK, below is what I am getting when I telnet into the mongrel serving out the same page.

GET /product_news HTTP/1.1
host: eqnow.myhost.net

HTTP/1.1 200 OK
Connection: close
Date: Mon, 15 Oct 2007 17:31:28 GMT
Set-Cookie: _eqnow_session_id=5ac326090f78036ec74829d470ef1547; path=/
Status: 200 OK
Cache-Control: no-cache
Server: Mongrel 1.0.1
Content-Type: text/html; charset=utf-8
Content-Length: 7489
.
.
.

Note I am not getting the extra Content-Length in the beginning. And why is litespeed server giving HTTP/1.1 404 not found when mongrel is saying HTTP/1.1 200 OK?

I think when the browser see the first Content-Length, it ignore the rest of the header and render the page as plain text, since it never to got to Content-Type: text/html.
 
Last edited:

mistwang

LiteSpeed Staff
#6
Your Rails application sent some thing before response header was sent to STDOUT, so the response header was treated as response body.
LiteSpeed use 404 handler for rails application, that's why you see 404 status code, instead of 200, because "Status: 200 OK" header was treated as response body, so 404 status code was used.
Maybe your developer dump some debug messages to STDOUT.
 
#7
Ok, thanks for the heads up. The developer was debugging something and send it to STDOUT. It's just mongrel ignore it, while Litespeed will put it through.

Guess this what happen what he work too long on it and forgot to comment out his debug code when done.
 
Top