Class: Pincers::Http::Session
- Inherits:
-
Object
- Object
- Pincers::Http::Session
- Defined in:
- lib/pincers/http/session.rb
Constant Summary collapse
- DEFAULT_HEADERS =
{ 'Accept' => '*/*', 'Cache-Control' => 'no-cache' }
Instance Attribute Summary collapse
-
#cookie_jar ⇒ Object
readonly
Returns the value of attribute cookie_jar.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#proxy_addr ⇒ Object
Returns the value of attribute proxy_addr.
-
#proxy_password ⇒ Object
Returns the value of attribute proxy_password.
-
#proxy_port ⇒ Object
Returns the value of attribute proxy_port.
-
#proxy_user ⇒ Object
Returns the value of attribute proxy_user.
-
#redirect_limit ⇒ Object
Returns the value of attribute redirect_limit.
-
#ssl_cert ⇒ Object
Returns the value of attribute ssl_cert.
-
#ssl_key ⇒ Object
Returns the value of attribute ssl_key.
Instance Method Summary collapse
- #clone ⇒ Object
-
#initialize(_other = nil) ⇒ Session
constructor
A new instance of Session.
- #perform(_request) ⇒ Object
- #proxy=(_value) ⇒ Object
- #proxy_auth=(_value) ⇒ Object
- #sync(_other) ⇒ Object
Constructor Details
#initialize(_other = nil) ⇒ Session
Returns a new instance of Session.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pincers/http/session.rb', line 17 def initialize(_other = nil) if _other @headers = _other.headers.clone @cookie_jar = _other..copy @proxy_addr = _other.proxy_addr @proxy_port = _other.proxy_port @redirect_limit = _other.redirect_limit @ssl_cert = _other.ssl_cert @ssl_key = _other.ssl_key else @headers = DEFAULT_HEADERS @cookie_jar = CookieJar.new @redirect_limit = 10 end end |
Instance Attribute Details
#cookie_jar ⇒ Object (readonly)
Returns the value of attribute cookie_jar.
13 14 15 |
# File 'lib/pincers/http/session.rb', line 13 def @cookie_jar end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
13 14 15 |
# File 'lib/pincers/http/session.rb', line 13 def headers @headers end |
#proxy_addr ⇒ Object
Returns the value of attribute proxy_addr.
14 15 16 |
# File 'lib/pincers/http/session.rb', line 14 def proxy_addr @proxy_addr end |
#proxy_password ⇒ Object
Returns the value of attribute proxy_password.
14 15 16 |
# File 'lib/pincers/http/session.rb', line 14 def proxy_password @proxy_password end |
#proxy_port ⇒ Object
Returns the value of attribute proxy_port.
14 15 16 |
# File 'lib/pincers/http/session.rb', line 14 def proxy_port @proxy_port end |
#proxy_user ⇒ Object
Returns the value of attribute proxy_user.
14 15 16 |
# File 'lib/pincers/http/session.rb', line 14 def proxy_user @proxy_user end |
#redirect_limit ⇒ Object
Returns the value of attribute redirect_limit.
14 15 16 |
# File 'lib/pincers/http/session.rb', line 14 def redirect_limit @redirect_limit end |
#ssl_cert ⇒ Object
Returns the value of attribute ssl_cert.
14 15 16 |
# File 'lib/pincers/http/session.rb', line 14 def ssl_cert @ssl_cert end |
#ssl_key ⇒ Object
Returns the value of attribute ssl_key.
14 15 16 |
# File 'lib/pincers/http/session.rb', line 14 def ssl_key @ssl_key end |
Instance Method Details
#clone ⇒ Object
49 50 51 |
# File 'lib/pincers/http/session.rb', line 49 def clone self.class.new self end |
#perform(_request) ⇒ Object
58 59 60 |
# File 'lib/pincers/http/session.rb', line 58 def perform(_request) perform_recursive _request, @redirect_limit end |
#proxy=(_value) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/pincers/http/session.rb', line 33 def proxy=(_value) if _value @proxy_addr, @proxy_port = _value.split ':' else @proxy_addr, @proxy_port = [nil, nil] end end |
#proxy_auth=(_value) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/pincers/http/session.rb', line 41 def proxy_auth=(_value) if _value @proxy_user, @proxy_password = _value.split ':' else @proxy_user, @proxy_password = [nil, nil] end end |
#sync(_other) ⇒ Object
53 54 55 56 |
# File 'lib/pincers/http/session.rb', line 53 def sync(_other) @headers.merge! _other.headers _other...each { |c| .set c } end |