lib/em-http/request.rb in em-http-request-0.2.6 vs lib/em-http/request.rb in em-http-request-0.2.7

- old
+ new

@@ -24,12 +24,11 @@ class HttpRequest attr_reader :options, :method - def initialize(host, headers = {}) - @headers = headers + def initialize(host) @uri = host.kind_of?(Addressable::URI) ? host : Addressable::URI::parse(host) end # Send an HTTP request and consume the response. Supported options: # @@ -70,11 +69,16 @@ # default connect & inactivity timeouts @options[:timeout] = 10 if not @options[:timeout] # Make sure the ports are set as Addressable::URI doesn't # set the port if it isn't there - @uri.port ||= 80 - @port_to_connect ||= 80 + if @uri.scheme == "https" + @uri.port ||= 443 + @port_to_connect ||= 443 + else + @uri.port ||= 80 + @port_to_connect ||= 80 + end @method = method.to_s.upcase send_request(&blk) end \ No newline at end of file