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? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 4, 1:16 pm, Xornor <pe...-ojGdcAoARxH1KXRcyAk9cg@public.gmane.org> wrote:> class ApplicationController < ActionController::Base > after_filter :customheaders > > private > > def customheaders > response.headers["Test header title"]="Test header value" > end > endThat looks like it should work (I don''t think that an after filter is ''too late'' to set headers). How are you testing that the headers aren''t there? Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> That looks like it should work (I don''t think that an after filter is > ''too late'' to set headers). How are you testing that the headers > aren''t there? > > FredI checked headers with two separate methods, by sending HTTP request with curl and -i option and also with Firefox Live HTTP headers - addon. I also tried to set custom headers in original controller component (no filters), but results were same. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 5, 2011, at 3:22 AM, Xornor wrote:> >> That looks like it should work (I don''t think that an after filter is >> ''too late'' to set headers). How are you testing that the headers >> aren''t there? >> >> Fred > > I checked headers with two separate methods, by sending HTTP request > with curl and -i option and also with Firefox Live HTTP headers - > addon. > > I also tried to set custom headers in original controller component > (no filters), but results were same. >Are you doing this at localhost, or in production behind a "real" Web server? Walter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 5 tammi, 15:15, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> On Jan 5, 2011, at 3:22 AM, Xornor wrote: > > > > >> That looks like it should work (I don''t think that an after filter is > >> ''too late'' to set headers). How are you testing that the headers > >> aren''t there? > > >> Fred > > > I checked headers with two separate methods, by sending HTTP request > > with curl and -i option and also with Firefox Live HTTP headers - > > addon. > > > I also tried to set custom headers in original controller component > > (no filters), but results were same. > > Are you doing this at localhost, or in production behind a "real" Web > server? > > WalterCurl 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". -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 5 Jan 2011, at 15:42, Xornor <petri-ojGdcAoARxH1KXRcyAk9cg@public.gmane.org> wrote:> >> >> > > 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? Fred> -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> > 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? body: !str str: "" "@_rails_html_safe": false body_exist: true code: "401" header: content-language: - en-US content-type: - text/plain connection: - close server: - IBM_HTTP_Server date: - Fri, 07 Jan 2011 09:13:26 GMT content-length: - "0" http_version: "1.1" message: Unauthorized read: true socket: -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.