Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(http): read_timout option in Session module #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.2.5
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.2.5
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