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.



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

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



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

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

#connected?Boolean

Can we use this connection to make requests?

Returns:

  • (Boolean)


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

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



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

def multiplex
  1
end

#peerObject



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

def peer
  @stream.io
end

#read_line?Boolean

Returns:

  • (Boolean)


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

def read_line?
  @stream.read_until(CRLF)
end

#reusable?Boolean

Returns:

  • (Boolean)


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

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