Class: HttpOptions
- Inherits:
-
Object
- Object
- HttpOptions
- Defined in:
- lib/em-http/http_options.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(method, uri, options) ⇒ HttpOptions
constructor
A new instance of HttpOptions.
Constructor Details
#initialize(method, uri, options) ⇒ HttpOptions
Returns a new instance of HttpOptions.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/em-http/http_options.rb', line 4 def initialize(method, uri, ) uri.path = '/' if uri.path.empty? @options = @method = method.to_s.upcase @uri = uri if proxy = [:proxy] @host = proxy[:host] @port = proxy[:port] else # optional host for cases where you may have # pre-resolved the host, or you need an override @host = .delete(:host) || uri.host @port = uri.port end @options[:timeout] ||= 10 # default connect & inactivity timeouts @options[:redirects] ||= 0 # default number of redirects to follow @options[:keepalive] ||= false # default to single request per connection # 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 @port ||= 443 else @uri.port ||= 80 @port ||= 80 end end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
2 3 4 |
# File 'lib/em-http/http_options.rb', line 2 def host @host end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
2 3 4 |
# File 'lib/em-http/http_options.rb', line 2 def method @method end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'lib/em-http/http_options.rb', line 2 def @options end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
2 3 4 |
# File 'lib/em-http/http_options.rb', line 2 def port @port end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
2 3 4 |
# File 'lib/em-http/http_options.rb', line 2 def uri @uri end |