Skip to content

Commit

Permalink
add read_timeout option
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskite committed Feb 17, 2011
1 parent 9efd04b commit 50f3cf3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/anemone/core.rb
Expand Up @@ -9,7 +9,7 @@

module Anemone

VERSION = '0.5.0';
VERSION = '0.6.0';

#
# Convenience method to start a crawl
Expand Down Expand Up @@ -53,7 +53,9 @@ class Core
# proxy server hostname
:proxy_host => nil,
# proxy server port number
:proxy_port => false
:proxy_port => false,
# HTTP read timeout in seconds
:read_timeout => nil
}

# Create setter methods for all options to be called from the crawl block
Expand Down
10 changes: 10 additions & 0 deletions lib/anemone/http.rb
Expand Up @@ -88,6 +88,13 @@ def proxy_port
@opts[:proxy_port]
end

#
# HTTP read timeout in seconds
#
def read_timeout
@opts[:read_timeout]
end

private

#
Expand Down Expand Up @@ -154,6 +161,9 @@ def connection(url)

def refresh_connection(url)
http = Net::HTTP::Proxy(proxy_host, proxy_port)

http.read_timeout = read_timeout if !!read_timeout

if url.scheme == 'https'
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
Expand Down

0 comments on commit 50f3cf3

Please sign in to comment.