# Strange behavior with a little racks app in thin

**URL:** <https://www.ruby-forum.com/t/strange-behavior-with-a-little-racks-app-in-thin/157107>\
**Category:** Ruby\
**Created:** [January 7, 2009, 12:33pm UTC](https://www.ruby-forum.com/t/strange-behavior-with-a-little-racks-app-in-thin/157107 "2009-01-07T12:33:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![saboteur](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7c8e57/32.png) [@saboteur](https://www.ruby-forum.com/u/saboteur)\
**Post date:** [January 7, 2009, 12:33pm UTC](https://www.ruby-forum.com/t/strange-behavior-with-a-little-racks-app-in-thin/157107/1 "2009-01-07T12:33:11Z")

</div>

Hi,  
I’m playing with thin and racks at the moment. I tried to built a really  
basic application:

# [test.ru](http://test.ru)

content=[“Is it working?  
**blublublub** ”]

app = proc do |env|  
[  
200, # Status code  
{ # Response headers  
‘Content-Type’ =\> ‘text/html’,  
‘Content-Length’ =\> “content[0].length”,  
},  
content[0]  
]  
end

run app

If I start it with: $ thin start -R [test.ru](http://test.ru)  
everything looks okay: No errors. Also when I access the webserver with  
my browser I don’t get no errors but the site displayed. But what seems  
strange is that my browser tries to take more data than it should  
actually take. So it displays the content but is trying to load even  
more. But there isn’t more data? Can someone explain this behavior? I’m  
sure I’m doing something wrong here or?

---

<div class="post-metadata">

**Author:** ![saboteur](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7c8e57/32.png) [@saboteur](https://www.ruby-forum.com/u/saboteur)\
**Post date:** [January 7, 2009, 4:15pm UTC](https://www.ruby-forum.com/t/strange-behavior-with-a-little-racks-app-in-thin/157107/2 "2009-01-07T16:15:56Z")

</div>

Thank you very much Brian that was the misstake:

$ telnet 127.0.0.1 3000  
Trying 127.0.0.1…  
Connected to 127.0.0.1.  
Escape character is ‘^]’.  
GET / HTTP/1.0

HTTP/1.1 200 OK  
Content-Type: text/html  
Content-Length: content[0].length  
Connection: close  
Server: thin 1.0.0 codename That’s What She Said

hi  
**ho** Connection closed by foreign host.

Correct syntax is “#{content[0].length}” . Without quotes thin is  
giving errors when trying to access the page: !! Unexpected error while  
processing request: undefined method `each’ for 15:Fixnum

kind regards

---

<div class="post-metadata">

**Author:** ![saboteur](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7c8e57/32.png) [@saboteur](https://www.ruby-forum.com/u/saboteur)\
**Post date:** [January 7, 2009, 2:07pm UTC](https://www.ruby-forum.com/t/strange-behavior-with-a-little-racks-app-in-thin/157107/3 "2009-01-07T14:07:43Z")

</div>

Karl Weasel wrote:

> ```
> 'Content-Length' => "content[0].length",
> 
> ```

Are you sure the right-hand side should be quoted? Look at the actual  
HTTP response returned. You can do this using tcpdump, wireshark, curl  
-v, or even plain old telnet:

telnet 127.0.0.1 80  
GET / HTTP/1.0

If you see

Content-Length: content[0].length

then you know there’s a problem 🙂

---

<div class="post-metadata">

**Author:** ![saboteur](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7c8e57/32.png) [@saboteur](https://www.ruby-forum.com/u/saboteur)\
**Post date:** [January 8, 2009, 10:51am UTC](https://www.ruby-forum.com/t/strange-behavior-with-a-little-racks-app-in-thin/157107/4 "2009-01-08T10:51:15Z")

</div>

Karl Weasel wrote:

> Correct syntax is “#{content[0].length}” . Without quotes thin is  
> giving errors when trying to access the page: !! Unexpected error while  
> processing request: undefined method `each’ for 15:Fixnum

Ah, then thin doesn’t like numbers as header values.

content[0].length.to\_s would be another solution.
