Module: Async::HTTP::Protocol::HTTP2::Connection

Included in:
Client, Server
Defined in:
lib/async/http/protocol/http2/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



68
69
70
# File 'lib/async/http/protocol/http2/connection.rb', line 68

def count
  @count
end

#streamObject (readonly)

Returns the value of attribute stream.



44
45
46
# File 'lib/async/http/protocol/http2/connection.rb', line 44

def stream
  @stream
end

Instance Method Details

#closeObject



88
89
90
91
92
93
# File 'lib/async/http/protocol/http2/connection.rb', line 88

def close
	Async.logger.debug(self) {"Closing connection"}
	
	@reader.stop if @reader
	@stream.close
end

#good?Boolean

Can we use this connection to make requests?

Returns:

  • (Boolean)


76
77
78
# File 'lib/async/http/protocol/http2/connection.rb', line 76

def good?
	@stream.connected?
end

#initializeObject



37
38
39
40
41
42
# File 'lib/async/http/protocol/http2/connection.rb', line 37

def initialize(*)
	super
	
	@count = 0
	@reader = nil
end

#multiplexObject

Only one simultaneous connection at a time.



71
72
73
# File 'lib/async/http/protocol/http2/connection.rb', line 71

def multiplex
	@remote_settings.maximum_concurrent_streams
end

#peerObject



64
65
66
# File 'lib/async/http/protocol/http2/connection.rb', line 64

def peer
	@stream.io
end

#read_in_background(task: Task.current) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/async/http/protocol/http2/connection.rb', line 50

def read_in_background(task: Task.current)
	task.async do |nested_task|
		nested_task.annotate("#{version} reading data")
		
		begin
			while !self.closed?
				self.read_frame
			end
		rescue
			Async.logger.debug(self) {$!}
		end
	end
end

#reusable?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/async/http/protocol/http2/connection.rb', line 80

def reusable?
	!(self.closed? || @stream.closed?)
end

#start_connectionObject



46
47
48
# File 'lib/async/http/protocol/http2/connection.rb', line 46

def start_connection
	@reader ||= read_in_background
end

#versionObject



84
85
86
# File 'lib/async/http/protocol/http2/connection.rb', line 84

def version
	VERSION
end