Sha256: 38bc2735cdee62e58102dee95ae37aed7ddd8d864c50f59050a9f0e9848cd52f
Contents?: true
Size: 1.28 KB
Versions: 3
Compression:
Stored size: 1.28 KB
Contents
class HttpOptions attr_reader :uri, :method, :host, :port, :options def initialize(uri, options, method = :none) @options = options @method = method.to_s.upcase set_uri(uri) @options[:keepalive] ||= false # default to single request per connection @options[:redirects] ||= 0 # default number of redirects to follow @options[:followed] ||= 0 # keep track of number of followed requests @options[:connect_timeout] ||= 5 # default connection setup timeout @options[:inactivity_timeout] ||= 10 # default connection inactivity (post-setup) timeout end def proxy @options[:proxy] end def follow_redirect? @options[:followed] < @options[:redirects] end def set_uri(uri) uri = uri.kind_of?(Addressable::URI) ? uri : Addressable::URI::parse(uri.to_s) uri.path = '/' if uri.path.empty? if path = @options.delete(:path) uri.path = path end @uri = uri # Make sure the ports are set as Addressable::URI doesn't # set the port if it isn't there if @uri.scheme == "https" @uri.port ||= 443 else @uri.port ||= 80 end if proxy = @options[:proxy] @host = proxy[:host] @port = proxy[:port] else @host = @uri.host @port = @uri.port end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
em-http-request-1.0.0.beta.3 | lib/em-http/http_options.rb |
em-http-request-1.0.0.beta.2 | lib/em-http/http_options.rb |
em-http-request-1.0.0.beta.1 | lib/em-http/http_options.rb |