class Session
Basically keeps track of cookies between the requests
Public Class Methods
new(default_options={})
click to toggle source
# File lib/under_os/http/session.rb, line 5 def initialize(default_options={}) @options = default_options @options[:cookies] ||= {} end
Public Instance Methods
delete(url, options={}, &block)
click to toggle source
# File lib/under_os/http/session.rb, line 26 def delete(url, options={}, &block) request(url, {method: 'DELETE'}.merge(options), &block).send end
get(url, options={}, &block)
click to toggle source
# File lib/under_os/http/session.rb, line 14 def get(url, options={}, &block) request(url, {method: 'GET'}.merge(options), &block).send end
post(url, options={}, &block)
click to toggle source
# File lib/under_os/http/session.rb, line 18 def post(url, options={}, &block) request(url, {method: 'POST'}.merge(options), &block).send end
put(url, options={}, &block)
click to toggle source
# File lib/under_os/http/session.rb, line 22 def put(url, options={}, &block) request(url, {method: 'PUT'}.merge(options), &block).send end
request(url, options={}, &block)
click to toggle source
# File lib/under_os/http/session.rb, line 30 def request(url, options={}, &block) options = options.merge(@options){|k,a,b| a.merge(b) } UnderOs::HTTP::Request.new(url, options, &block).tap do |request| request.on :response do |response| save_cookies response.headers["Set-Cookie"] || '' end end end