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.



16
17
18
19
20
21
# File 'lib/async/http/protocol/http1/connection.rb', line 16

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

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



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

def count
  @count
end

#versionObject (readonly)

Returns the value of attribute version.



23
24
25
# File 'lib/async/http/protocol/http1/connection.rb', line 23

def version
  @version
end

Instance Method Details

#concurrencyObject



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

def concurrency
	1
end

#http1?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/async/http/protocol/http1/connection.rb', line 25

def http1?
	true
end

#http2?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/async/http/protocol/http1/connection.rb', line 29

def http2?
	false
end

#peerObject



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

def peer
	@stream.io
end

#read_lineObject



37
38
39
# File 'lib/async/http/protocol/http1/connection.rb', line 37

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

#read_line?Boolean

Returns:

  • (Boolean)


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

def read_line?
	@stream.read_until(CRLF)
end

#reusable?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/async/http/protocol/http1/connection.rb', line 56

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

#viable?Boolean

Can we use this connection to make requests?

Returns:

  • (Boolean)


52
53
54
# File 'lib/async/http/protocol/http1/connection.rb', line 52

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