BUG: send_data, CONTENT TYPE not set

74 views
Skip to first unread message

fx3000se

unread,
Aug 11, 2008, 10:22:35 AM8/11/08
to Ruby on Rails: Core
--> http://railsforum.com/viewtopic.php?pid=71435#p71435
bug or feature?
Thanks in advance
Clemens

Michael Koziarski

unread,
Aug 11, 2008, 10:43:44 AM8/11/08
to rubyonra...@googlegroups.com
worksforme

--
Cheers

Koz

Frederick Cheung

unread,
Aug 11, 2008, 11:14:05 AM8/11/08
to rubyonra...@googlegroups.com

On 11 Aug 2008, at 15:43, Michael Koziarski wrote:

>
> worksforme
>
I had a look - when actually running through the browser, a Content-
Type header is sent out as you would expect, but inside functional
tests it does look a bit odd.

The interesting method in response.rb is

def convert_content_type!
if content_type = headers.delete("Content-Type")
self.headers["type"] = content_type
end
if content_type = headers.delete("Content-type")
self.headers["type"] = content_type
end
if content_type = headers.delete("content-type")
self.headers["type"] = content_type
end
end

Ruby's cgi library in turn will convert a type entry into a Content-
Type one (you can see this in cgi.rb, in the header method)
Don't know why it does this (i've always thought of cgi.rb as rather
crufty)

Fred

fx3000se

unread,
Aug 11, 2008, 11:04:03 AM8/11/08
to Ruby on Rails: Core
what environment do you have?

Mine:
win32
ruby 1.8.6-p111
rails 2.1.0
(mongrel 1.1.5 which is not relevant for the testcase)

fx3000se

unread,
Aug 11, 2008, 12:12:13 PM8/11/08
to Ruby on Rails: Core
Hence Response>>convert_content_type! must have changed/entered btw
rails 1.1.6 and 2.1.0

Frederick Cheung

unread,
Aug 12, 2008, 6:29:17 AM8/12/08
to rubyonra...@googlegroups.com

On 11 Aug 2008, at 17:12, fx3000se wrote:

>
> Hence Response>>convert_content_type! must have changed/entered btw
> rails 1.1.6 and 2.1.0
>

What I was trying to explain was that it doesn't matter - cgi.rb
converts the type option to a Content-Type one when it writes the header

Inside a test of course you don't go via cgi and so you see the
difference you noted.
You can isolate yourself from that difference by going via
@response.content_type

Fred

Reply all
Reply to author
Forward
0 new messages