diff options
author | Tore Darell <toredarell@gmail.com> | 2008-11-05 00:04:40 +0100 |
---|---|---|
committer | Tore Darell <toredarell@gmail.com> | 2008-11-05 00:04:40 +0100 |
commit | 6e48cd202cae0f5fc7419d368e70070aa35b0fc5 (patch) | |
tree | 82f9cc73228732d5fe6222deae026771b40ba0b0 | |
parent | 4adbaadad362e0a3e30cf9ffbca9c3808561077e (diff) | |
download | rails-6e48cd202cae0f5fc7419d368e70070aa35b0fc5.tar.gz rails-6e48cd202cae0f5fc7419d368e70070aa35b0fc5.tar.bz2 rails-6e48cd202cae0f5fc7419d368e70070aa35b0fc5.zip |
Add example to show how to add additional headers using the response object
-rw-r--r-- | railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt b/railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt index a9c65c31bc..06844f0a1e 100644 --- a/railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt +++ b/railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt @@ -31,3 +31,13 @@ The response object is not usually used directly, but is built up during the exe * location - The URL the client is being redirected to, if any. * content_type - The content type of the response. * charset - The character set being used for the response. Default is "utf8". + * headers - Headers used for the response. + +==== Setting custom headers ==== + +If you want to set custom headers for a response then `response.headers` is the place to do it. The headers attribute is a hash which maps header names to their values, and Rails will set some of them - like "Content-Type" - automatically. If you want to add or change a header, just assign it to `headers` with the name and value: + +[source, ruby] +------------------------------------- +response.headers["Content-Type"] = "application/pdf" +------------------------------------- |