Method: MTUV::HttpEndpoint#initialize

Defined in:
lib/mt-uv-rays/http_endpoint.rb

#initialize(host, options = {}) ⇒ HttpEndpoint

Returns a new instance of HttpEndpoint.



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/mt-uv-rays/http_endpoint.rb', line 144

def initialize(host, options = {})
    @queue = []
    @parser = Http::Parser.new
    @thread = reactor
    @connection = nil

    @options = @@defaults.merge(options)
    @tls_options = options[:tls_options] || {}
    @inactivity_timeout = options[:inactivity_timeout] || 10000

    uri = host.is_a?(::URI) ? host : ::URI.parse(host)
    @port = uri.port
    @host = uri.host

    default_port = uri.port == uri.default_port
    @encoded_host = default_port ? @host : "#{@host}:#{@port}"
    @proxy = @options[:proxy]

    @scheme = uri.scheme
    @tls = @scheme == 'https'
    @cookiejar = CookieJar.new
    @middleware = []

    @closing = false
    @connecting = false
end