Topic: Net::HTTP:Request setting the cookies
I'm working on an app that performs a pseudo proxy function. I would like to take cookies previously retrieved from a response and add them to a new request. Thanks for taking a look.
ie
http = Net::HTTP.new('www.facebook.com', 80)
#http.use_ssl = true
resp = nil
cookie = String.new http.start do |http|
request = Net::HTTP::Post.new('/')
request['referer'] = 'http://www.example.com/'
request['user-agent'] = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008051206 Firefox/3.0'
resp = http.request(request)
cookie = resp['Set-Cookie']
end
http = Net::HTTP.new('www.samplesite.com', 443)
http.use_ssl = true
http.start do |http|
request = Net::HTTP::Post.new('/login.php')
######
#Here is where I need an example
######
request['Cookie'] = ?????
######
request['user-agent'] = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008051206 Firefox/3.0'
resp = http.request(request)
resp.value
end