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.
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.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pincers/http/session.rb', line 16 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 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 |
Instance Method Details
#clone ⇒ Object
46 47 48 |
# File 'lib/pincers/http/session.rb', line 46 def clone self.class.new self end |
#perform(_request) ⇒ Object
55 56 57 |
# File 'lib/pincers/http/session.rb', line 55 def perform(_request) perform_recursive _request, @redirect_limit end |
#proxy=(_value) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/pincers/http/session.rb', line 30 def proxy=(_value) if _value @proxy_addr, @proxy_port = _value.split ':' else @proxy_addr, @proxy_port = [nil, nil] end end |
#proxy_auth=(_value) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/pincers/http/session.rb', line 38 def proxy_auth=(_value) if _value @proxy_user, @proxy_password = _value.split ':' else @proxy_user, @proxy_password = [nil, nil] end end |
#sync(_other) ⇒ Object
50 51 52 53 |
# File 'lib/pincers/http/session.rb', line 50 def sync(_other) @headers.merge! _other.headers _other...each { |c| .set c } end |