ruby - Sending POST requests from Rails controller for authentication -


i quite new ruby , ror, , have been struggling problem , not getting anywhere.

basically building "proxy" webservice handle requests, passing them third party website. response received third party website in html, parsed , appropriate xml response given.

i'm @ point need send post requests via controller in rails authenticate user, i'm doing using code:

require "net/http" require "uri"  uri = uri.parse("http://myurl.com/members.cgi")  http = net::http.new(uri.host, uri.port) request = net::http::post.new(uri.request_uri) request.set_form_data({"email_login" => "user@email.com", "password_login" => "password"}) response = http.request(request) 

my problem lies on response receiving. specific post request, when successful (i.e. user has authenticated), returning 302 redirect. in not issue, can follow redirect getting 'location' header value:

redirectlocation = response['location'] 

where i'm getting stuck in keeping myself authenticated when following redirect following line:

redirectresponse = net::http.get_response(uri.parse(redirectlocation)) 

this follows redirect return response showing not authenticated??

i don't understanding why happening. can see there authentication cookie being returned original response reading:

response['cookie'] 

so question need server recognise authentication status? pass cookie second request somehow? if so, how do it?

many in advance time!

rog

yes need set cookie. think give kind of session id. need pass every request.

look @ this code snippet example on how pass on cookie response new requests.


Comments