Skip to content

Commit

Permalink
feat(http): read_timout option before request
Browse files Browse the repository at this point in the history
  • Loading branch information
mariowise committed Dec 6, 2016
1 parent 7620f44 commit 84eb4df
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
language: ruby
script: bundle exec rspec spec
rvm:
- 2.0.0
- 2.3.0
sudo: false
1 change: 1 addition & 0 deletions lib/pincers/http/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def self.build_from_options(_options = {})
session.proxy_auth = _options[:proxy_auth] if _options.key? :proxy_auth
session.headers.merge! _options[:headers] if _options.key? :headers
session.redirect_limit = _options[:redirect_limit] if _options.key? :redirect_limit
session.read_timeout = _options[:read_timeout] if _options.key? :read_timeout

if _options.key? :ssl_cert
session.ssl_cert = _options[:ssl_cert]
Expand Down
5 changes: 4 additions & 1 deletion lib/pincers/http/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Session

attr_reader :cookie_jar, :headers
attr_accessor :proxy_addr, :proxy_port, :proxy_user, :proxy_password, :redirect_limit,
:ssl_cert, :ssl_key
:ssl_cert, :ssl_key, :read_timeout

def initialize(_other = nil)
if _other
Expand All @@ -23,6 +23,7 @@ def initialize(_other = nil)
@redirect_limit = _other.redirect_limit
@ssl_cert = _other.ssl_cert
@ssl_key = _other.ssl_key
@read_timeout = _other.read_timeout || 60
else
@headers = DEFAULT_HEADERS
@cookie_jar = CookieJar.new
Expand Down Expand Up @@ -104,6 +105,8 @@ def connect(_uri)
proxy_password
)

conn.read_timeout = read_timeout

conn.use_ssl = true if _uri.scheme == 'https'

if ssl_cert
Expand Down

0 comments on commit 84eb4df

Please sign in to comment.