class Async::HTTP::Protocol::HTTP1::Request

def self.read(connection)

def self.read(connection)
	connection.read_request do |authority, method, target, version, headers, body|
		if method == ::Protocol::HTTP::Methods::CONNECT
			# We put the target into the authority field for CONNECT requests, as per HTTP/2 semantics.
			self.new(connection, nil, target, method, nil, version, headers, body)
		elsif valid_path?(target)
			# This is a valid request.
			self.new(connection, nil, authority, method, target, version, headers, body)
		elsif match = target.match(URI_PATTERN)
			# We map the incoming absolute URI target to the scheme, authority, and path fields of the request.
			self.new(connection, match[:scheme], match[:authority], method, match[:path], version, headers, body)
		else
			# This is an invalid request.
			raise ::Protocol::HTTP1::BadRequest.new("Invalid request target: #{target}")
		end
	end
end