Module: Async::HTTP::Protocol::HTTP1::Connection

Constant Summary collapse

CRLF =
"\r\n"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



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

def count
  @count
end

#streamObject (readonly)

Returns the value of attribute stream.



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

def stream
  @stream
end

Instance Method Details

#closeObject



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

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

#connected?Boolean

Can we use this connection to make requests?

Returns:

  • (Boolean)


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

def connected?
	@stream.connected?
end

#hijackAsync::Wrapper

Returns the underlying non-blocking IO.

Returns:

  • (Async::Wrapper)

    the underlying non-blocking IO.



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

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

#multiplexObject



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

def multiplex
	1
end

#peerObject



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

def peer
	@stream.io
end

#read_chunked_bodyObject



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

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

#read_fixed_body(length) ⇒ Object



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

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

#read_lineObject



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

def read_line
	@stream.read_until(CRLF) or raise EOFError
end

#read_remainder_bodyObject



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

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

#read_tunnel_bodyObject



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

def read_tunnel_body
	read_remainder_body
end

#reusable?Boolean

Returns:

  • (Boolean)


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

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