I have to change all headers in Ruby on rails response message. This
must be done because my application should read another www-page from
the other server and then send it to the client such as it comes from
the original web server.
I thought first that it is easy to change headers in class
ApplicationController < ActionController::Base by creating after
filter following way:
class ApplicationController < ActionController::Base
after_filter :customheaders
private
def customheaders
response.headers["Test header title"]="Test header value"
end
end
However, my application sends always just default headers. I know that
the after filter works because if I change body content in
customheaders -function, it works (response.body = "New body
content").
The application renders web page normally in a view-component. Rails
version is 3.0.3.
Would anyone know how I could change all headers of the response
message in application controller?
Curl was used in the same server (Ubuntu) as application is executed.
Firefox was running in the another computer.
I made changes directly to the application which was running in the
server. The server is in “production”.
Dumb question: are you sure your changes are actually in use (ie whatever needs to be restarted has been restarted)? Can you replicate this on your development machine?
Dumb question: are you sure your changes are actually in use (ie whatever needs to be restarted has been restarted)? Can you replicate this on your development machine?
All other changes come in use as I expect? What could not be in use?
I tried to debug content of the response object and oddly if I render
it at the end of the view component ( <%= debug response %>), header
content is fine. It is exactly such as I expect. But when I check
headers of the received HTTP message, they are different than in
response object?
Could this problem happen because I get unauthorized message from the
original server and I try to use headers of it in normal Ruby on rails
response message?