class Async::HTTP::Protocol::HTTP2::Request::Stream

def closed(error)

def closed(error)
	@request = nil
	
	super
end

def initialize(*)

def initialize(*)
	super
	
	@enqueued = false
	@request = Request.new(self)
end

def receive_initial_headers(headers, end_stream)

def receive_initial_headers(headers, end_stream)
	@headers = ::Protocol::HTTP::Headers.new
	
	headers.each do |key, value|
		if key == SCHEME
			raise ::Protocol::HTTP2::HeaderError, "Request scheme already specified!" if @request.scheme
			
			@request.scheme = value
		elsif key == AUTHORITY
			raise ::Protocol::HTTP2::HeaderError, "Request authority already specified!" if @request.authority
			
			@request.authority = value
		elsif key == METHOD
			raise ::Protocol::HTTP2::HeaderError, "Request method already specified!" if @request.method
			
			@request.method = value
		elsif key == PATH
			raise ::Protocol::HTTP2::HeaderError, "Request path is empty!" if value.empty?
			raise ::Protocol::HTTP2::HeaderError, "Request path already specified!" if @request.path
			
			@request.path = value
		elsif key == PROTOCOL
			raise ::Protocol::HTTP2::HeaderError, "Request protocol already specified!" if @request.protocol
			
			@request.protocol = value
		elsif key == CONTENT_LENGTH
			raise ::Protocol::HTTP2::HeaderError, "Request content length already specified!" if @length
			
			@length = Integer(value)
		elsif key == CONNECTION
			raise ::Protocol::HTTP2::HeaderError, "Connection header is not allowed!"
		elsif key.start_with? ":"
			raise ::Protocol::HTTP2::HeaderError, "Invalid pseudo-header #{key}!"
		elsif key =~ /[A-Z]/
			raise ::Protocol::HTTP2::HeaderError, "Invalid characters in header #{key}!"
		else
			add_header(key, value)
		end
	end
	
	@request.headers = @headers
	
	unless @request.valid?
		raise ::Protocol::HTTP2::HeaderError, "Request is missing required headers!"
	else
		# We only construct the input/body if data is coming.
		unless end_stream
			@request.body = prepare_input(@length)
		end
		
		# We are ready for processing:
		@connection.requests.enqueue(@request)
	end
	
	return headers
end