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

Inherits:
HTTP::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.



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

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

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



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

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

#closeObject



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

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

#connected?Boolean

Can we use this connection to make requests?

Returns:

  • (Boolean)


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

def connected?
	@stream.connected?
end

#hijackAsync::Wrapper

Returns the underlying non-blocking IO.

Returns:

  • (Async::Wrapper)

    the underlying non-blocking IO.



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

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

#multiplexObject



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

def multiplex
	1
end

#peerObject



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

def peer
	@stream.io
end

#read_chunked_bodyObject



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

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

#read_fixed_body(length) ⇒ Object



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

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

#read_lineObject



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

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

#read_remainder_bodyObject



93
94
95
# File 'lib/async/http/protocol/http1/connection.rb', line 93

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

#read_tunnel_bodyObject



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

def read_tunnel_body
	read_remainder_body
end

#reusable?Boolean

Returns:

  • (Boolean)


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

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