I am creating a rails app that is a gui wraping a restful web service that uses a websso for authentication. This websso sets a series of headers that I need to pass from the request to the ActiveResource.find methods. As this is stuff like username etc it is going to be different for each request. I can find examples on how to set headers for all requests not just one. Does anyone know of a way of doing this Thanks in advance Tom -- 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.
Something at the Rack level, maybe? -- 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 Thu, Dec 30, 2010 at 11:58 PM, Tom <tomjmalone-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am creating a rails app that is a gui wraping a restful web service > that uses a websso for authentication. This websso sets a series of > headers that I need to pass from the request to the > ActiveResource.find methods. As this is stuff like username etc it is > going to be different for each request. I can find examples on how to > set headers for all requests not just one."set" or do you actually mean "get" ? If you need to *read* headers from a request you should do that in your controller; unsurprisingly they''re in a ''request.headers'' array :-) HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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.
Ok it might be easier to show you type of thing I want to do. class ActionsController < ApplicationController def index @actions = CorporateAction.all(:headers => request.headers) end def show @action = CorporateAction.find(params[:id], :headers => request.headers) end end Where CorporateAction is an ActiveResource ie class CorporateAction < ActiveResource::Base self.site = "http://localhost:3000" self.format = :json end Is this possible or is there another way of doing it? Tom On Dec 31 2010, 4:57 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Dec 30, 2010 at 11:58 PM, Tom <tomjmal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I am creating a rails app that is a gui wraping a restful web service > > that uses a websso for authentication. This websso sets a series of > > headers that I need to pass from the request to the > > ActiveResource.find methods. As this is stuff like username etc it is > > going to be different for each request. I can find examples on how to > > set headers for all requests not just one. > > "set" or do you actually mean "get" ? > > If you need to *read* headers from a request you should do that in > your controller; unsurprisingly they''re in a ''request.headers'' array :-) > > HTH, > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > twitter: @hassan-- 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 Sun, Jan 2, 2011 at 11:34 AM, Tom <tomjmalone-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ok it might be easier to show you type of thing I want to do. > > class ActionsController < ApplicationController > def index > @actions = CorporateAction.all(:headers => request.headers) > end > > def show > @action = CorporateAction.find(params[:id], :headers => > request.headers) > end > end > > Where CorporateAction is an ActiveResource ie > > class CorporateAction < ActiveResource::Base > self.site = "http://localhost:3000" > self.format = :json > end > > Is this possible or is there another way of doing it?Is *what* possible? None of the above makes any sense to me -- can you describe *exactly* your goal? -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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.
I am faced with the exact same scenario, an OAuth authentication is accepted on a request and needs to be used on an ActiveResource lookup call to a RESTful API, that itself requires the appropriate authentication header to be set, possibly different for each HTTP request. This seems to me to be a legitimate and possibly popular way to use ActiveResource in the development community. I don''t have a workaround yet, I am hoping my post raises awareness. Thanks, -Ken On Dec 31 2010, 2:58 am, Tom <tomjmal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am creating a rails app that is a gui wraping a restful web service > that uses a websso for authentication. This websso sets a series of > headers that I need to pass from the request to the > ActiveResource.find methods. As this is stuff like username etc it is > going to be different for each request. I can find examples on how to > set headers for all requests not just one. > > Does anyone know of a way of doing this > > Thanks in advance > > Tom-- 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.
Does active resource support setting headers on the model object rather then on the model class? That would solve the issue, but looking thought the active resource code does not seem that it''s available. Any good reason why should the option of setting headers per object not be supported/provided/available? Dmitry On Jan 4, 9:54 am, ken <ken.mccrac...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am faced with the exact same scenario, an OAuth authentication is > accepted on a request and needs to be used on an ActiveResource lookup > call to a RESTful API, that itself requires the appropriate > authentication header to be set, possibly different for each HTTP > request. This seems to me to be a legitimate and possibly popular way > to use ActiveResource in the development community. > > I don''t have a workaround yet, I am hoping my post raises awareness. > > Thanks, > -Ken > > On Dec 31 2010, 2:58 am, Tom <tomjmal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > I am creating a rails app that is a gui wraping a restful web service > > that uses a websso for authentication. This websso sets a series of > > headers that I need to pass from the request to the > > ActiveResource.find methods. As this is stuff like username etc it is > > going to be different for each request. I can find examples on how to > > set headers for all requests not just one. > > > Does anyone know of a way of doing this > > > Thanks in advance > > > Tom-- 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 Tue, Jan 4, 2011 at 7:20 AM, dmitry <dmitryame-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Does active resource support setting headers on the model object > rather then on the model class? > That would solve the issue, but looking thought the active resource > code does not seem that it''s available. > > Any good reason why should the option of setting headers per object > not be supported/provided/available?(Rails 3.0.3) ActiveResource::Connection lists get(path, headers = {}) as a public instance method; is that not what you want? (''headers'' is also part of other ReSTful verbs e.g. put/post/etc. method signatures) -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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.
So, how exactly do i set a unique headers for each individual request? Here is the implementation from the ActiveResource code: def update connection.put(element_path(prefix_options), encode, self.class.headers).tap do |response| load_attributes_from_response(response) end end As you can see it does not respect the headers set on the object, instead it always reads the headers from the class Am I getting it wrong? Dmitry On Jan 4, 10:50 am, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Jan 4, 2011 at 7:20 AM, dmitry <dmitry...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Does active resource support setting headers on the model object > > rather then on the model class? > > That would solve the issue, but looking thought the active resource > > code does not seem that it''s available. > > > Any good reason why should the option of setting headers per object > > not be supported/provided/available? > > (Rails 3.0.3) ActiveResource::Connection lists > > get(path, headers = {}) > > as a public instance method; is that not what you want? (''headers'' is > also part of other ReSTful verbs e.g. put/post/etc. method signatures) > > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > twitter: @hassan-- 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 Tue, Jan 4, 2011 at 10:31 AM, dmitry <dmitryame-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> So, how exactly do i set a unique headers for each individual request?> As you can see it does not respect the headers set on the object, > instead it always reads the headers from the class > > Am I getting it wrong?Looks like a discrepancy between the docs and reality :-) I''ve never tried this before, but I don''t see how to do it either. Sorry! -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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.