Class: Async::HTTP::Protocol::HTTP2::Client

Inherits:
Protocol::HTTP2::Client
  • Object
show all
Includes:
Connection
Defined in:
lib/async/http/protocol/http2/client.rb

Instance Attribute Summary

Attributes included from Connection

#count, #promises, #stream

Instance Method Summary collapse

Methods included from Connection

#close, #concurrency, #http1?, #http2?, #peer, #read_in_background, #reusable?, #start_connection, #to_s, #version, #viable?, #write_frame, #write_frames

Constructor Details

#initialize(stream) ⇒ Client

Returns a new instance of Client.



35
36
37
38
39
40
41
# File 'lib/async/http/protocol/http2/client.rb', line 35

def initialize(stream)
	@stream = stream
	
	framer = ::Protocol::HTTP2::Framer.new(@stream)
	
	super(framer)
end

Instance Method Details

#call(request) ⇒ Object

Used by the client to send requests to the remote server.

Raises:

  • (::Protocol::HTTP2::Error)


48
49
50
51
52
53
54
55
56
57
58
# File 'lib/async/http/protocol/http2/client.rb', line 48

def call(request)
	raise ::Protocol::HTTP2::Error, "Connection closed!" if self.closed?
	
	@count += 1
	
	response = create_response
	response.send_request(request)
	response.wait
	
	return response
end

#create_responseObject



43
44
45
# File 'lib/async/http/protocol/http2/client.rb', line 43

def create_response
	Response::Stream.create(self, self.next_stream_id).response
end