class Async::HTTP::Protocol::HTTP2

def send_request(authority, method, path, headers = {}, body = nil)

def send_request(authority, method, path, headers = {}, body = nil)
	stream = @controller.new_stream
	
	internal_headers = {
		SCHEME => HTTPS,
		METHOD => method,
		PATH => path,
		AUTHORITY => authority,
	}.merge(headers)
	
	stream.headers(internal_headers, end_stream: true)
	
	# if body
	# 	body.each do |chunk|
	# 		stream.data(chunk, end_stream: false)
	# 	end
	# 
	# 	stream.data("", end_stream: true)
	# end
	
	response = Response.new
	response.version = RESPONSE_VERSION
	response.headers = Headers.new
	response.body = Async::IO::BinaryString.new
	
	stream.on(:headers) do |headers|
		# Async.logger.debug(self) {"Stream headers: #{headers.inspect}"}
		
		headers.each do |key, value|
			if key == STATUS
				response.status = value.to_i
			elsif key == REASON
				response.reason = value
			else
				response.headers[key] = value
			end
		end
	end
	
	stream.on(:data) do |body|
		# Async.logger.debug(self) {"Stream data: #{body.size} bytes"}
		response.body << body
	end
	
	finished = Async::Notification.new
	
	stream.on(:half_close) do
		# Async.logger.debug(self) {"Stream half-closed."}
	end
	
	stream.on(:close) do
		# Async.logger.debug(self) {"Stream closed, sending signal."}
		finished.signal
	end
	
	@stream.flush
	
	# Async.logger.debug(self) {"Stream flushed, waiting for signal."}
	finished.wait
	
	# Async.logger.debug(self) {"Stream finished: #{response.inspect}"}
	return response
end