Class: Async::HTTP::Protocol::HTTP1::Connection

Inherits:
Protocol::HTTP1::Connection
  • Object
show all
Defined in:
lib/async/http/protocol/http1/connection.rb

Direct Known Subclasses

Client, Server

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream, version) ⇒ Connection

Returns a new instance of Connection.



33
34
35
36
37
38
# File 'lib/async/http/protocol/http1/connection.rb', line 33

def initialize(stream, version)
	super(stream)
	
	@ready = true
	@version = version
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



62
63
64
# File 'lib/async/http/protocol/http1/connection.rb', line 62

def count
  @count
end

#versionObject (readonly)

Returns the value of attribute version.



40
41
42
# File 'lib/async/http/protocol/http1/connection.rb', line 40

def version
  @version
end

Instance Method Details

#concurrencyObject



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

def concurrency
	1
end

#http1?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/async/http/protocol/http1/connection.rb', line 42

def http1?
	true
end

#http2?Boolean

Returns:

  • (Boolean)


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

def http2?
	false
end

#peerObject



58
59
60
# File 'lib/async/http/protocol/http1/connection.rb', line 58

def peer
	@stream.io
end

#read_lineObject



54
55
56
# File 'lib/async/http/protocol/http1/connection.rb', line 54

def read_line
	@stream.read_until(CRLF) or raise EOFError, "Could not read line!"
end

#read_line?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/async/http/protocol/http1/connection.rb', line 50

def read_line?
	@stream.read_until(CRLF)
end

#reusable?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/async/http/protocol/http1/connection.rb', line 73

def reusable?
	@ready && @persistent && @stream && !@stream.closed?
end

#viable?Boolean

Can we use this connection to make requests?

Returns:

  • (Boolean)


69
70
71
# File 'lib/async/http/protocol/http1/connection.rb', line 69

def viable?
	@ready && @stream&.connected?
end