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.



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

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

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



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

def count
  @count
end

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#closeObject



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

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

#connected?Boolean

Can we use this connection to make requests?

Returns:

  • (Boolean)


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

def connected?
	@stream.connected?
end

#hijack!Async::Wrapper

Returns the underlying non-blocking IO.

Returns:

  • (Async::Wrapper)

    the underlying non-blocking IO.



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

def hijack!
	@persistent = false
	
	@stream.flush
	
	return @stream.io
end

#multiplexObject



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

def multiplex
	1
end

#peerObject



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

def peer
	@stream.io
end

#read_chunked_bodyObject



82
83
84
# File 'lib/async/http/protocol/http1/connection.rb', line 82

def read_chunked_body
	Body::Chunked.new(self)
end

#read_fixed_body(length) ⇒ Object



86
87
88
# File 'lib/async/http/protocol/http1/connection.rb', line 86

def read_fixed_body(length)
	Body::Fixed.new(@stream, length)
end

#read_line?Boolean

Returns:

  • (Boolean)


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

def read_line?
	@stream.read_until(CRLF)
end

#read_remainder_bodyObject



90
91
92
# File 'lib/async/http/protocol/http1/connection.rb', line 90

def read_remainder_body
	Body::Remainder.new(@stream)
end

#reusable?Boolean

Returns:

  • (Boolean)


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

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