Skip to content
Browse files

Add example to show how to add additional headers using the response …

  • Loading branch information...
1 parent 4adbaad commit 6e48cd202cae0f5fc7419d368e70070aa35b0fc5 @toretore toretore committed
Showing with 10 additions and 0 deletions.
  1. +10 −0 railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt
10 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"

0 comments on commit 6e48cd2

Please sign in to comment.
Something went wrong with that request. Please try again.