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.



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

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

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



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

def count
  @count
end

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#closeObject



77
78
79
80
# File 'lib/async/http/protocol/http1/connection.rb', line 77

def close
	Async.logger.debug(self) {"Closing connection"}
	super
end

#connected?Boolean

Can we use this connection to make requests?

Returns:

  • (Boolean)


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

def connected?
	@stream&.connected?
end

#http1?Boolean

Returns:

  • (Boolean)


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

def http1?
	true
end

#http2?Boolean

Returns:

  • (Boolean)


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

def http2?
	false
end

#multiplexObject



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

def multiplex
	1
end

#peerObject



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

def peer
	@stream.io
end

#read_lineObject



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

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

#read_line?Boolean

Returns:

  • (Boolean)


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

def read_line?
	@stream.read_until(CRLF)
rescue Errno::ECONNRESET
	return nil
end

#reusable?Boolean

Returns:

  • (Boolean)


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

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