Class: UV::HttpEndpoint::Connection

Inherits:
OutboundConnection show all
Defined in:
lib/uv-rays/http_endpoint.rb

Instance Attribute Summary collapse

Attributes inherited from Connection

#using_tls

Instance Method Summary collapse

Methods inherited from OutboundConnection

#reconnect, #use_tls

Methods inherited from TcpConnection

#keepalive, #stream_file, #write

Methods inherited from Connection

#pause, #paused?, #resume

Constructor Details

#initialize(host, port, tls, client) ⇒ Connection

Returns a new instance of Connection.



38
39
40
41
42
43
44
45
46
47
# File 'lib/uv-rays/http_endpoint.rb', line 38

def initialize(host, port, tls, client)
    @client = client
    @request = nil
    super(host, port)

    if tls
        opts = {host_name: host}.merge(client.tls_options)
        use_tls(opts)
    end
end

Instance Attribute Details

#reason ⇒ Object

Returns the value of attribute reason.



49
50
51
# File 'lib/uv-rays/http_endpoint.rb', line 49

def reason
  @reason
end

#request ⇒ Object

Returns the value of attribute request.



49
50
51
# File 'lib/uv-rays/http_endpoint.rb', line 49

def request
  @request
end

Instance Method Details

#close_connection(request = nil) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/uv-rays/http_endpoint.rb', line 70

def close_connection(request = nil)
    if request.is_a? Http::Request
        @request = request
        super(:after_writing)
    else
        super(request)
    end
end

#on_close ⇒ Object

user to define



62
63
64
65
66
67
68
# File 'lib/uv-rays/http_endpoint.rb', line 62

def on_close # user to define
    @client.connection_closed(@request, @reason)
ensure
    @request = nil
    @client = nil
    @reason = nil
end

#on_connect(transport) ⇒ Object

user to define



58
59
60
# File 'lib/uv-rays/http_endpoint.rb', line 58

def on_connect(transport) # user to define
    @client.connection_ready
end

#on_read(data, *args) ⇒ Object

user to define



51
52
53
# File 'lib/uv-rays/http_endpoint.rb', line 51

def on_read(data, *args) # user to define
    @client.data_received(data)
end

#post_init(*args) ⇒ Object



55
56
# File 'lib/uv-rays/http_endpoint.rb', line 55

def post_init(*args)
end