Forum: Ruby on Rails Set HTTP headers on response?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jeff J. (Guest)
on 2006-02-17 19:35
Is it possible to set HTTP headers for a response?

Seeing as you can access the headers using the request.env["FOO"] I am
wondering if there is an equivalent response.env["BAR"], this is a wild
guess and I have seen no documentation to back it up.

Has anyone managed to do this somehow?


Mikkel B. (Guest)
on 2006-02-17 20:22
(Received via mailing list)
On Friday, February 17, 2006, at 6:35 PM, Jeff J. wrote:

@headers["foo"]="bar" is the shiznit...

Mikkel B.    - Football Portal(DK) - Football News(DK)      - Buy Old Stuff!(DK)
Brian V. Hughes (Guest)
on 2006-02-17 20:31
(Received via mailing list)
Jeff J. wrote:
> Is it possible to set HTTP headers for a response?

Of course... what you want to use is the headers hash, it works similar
params and session.

   headers["Code"] = 404
   headers["Content-Type"] = "text/plain"

This topic is locked and can not be replied to.