class Async::HTTP::Protocol::HTTP11

def receive_requests(task: Task.current)

Server loop.
def receive_requests(task: Task.current)
	while request = next_request
		response = yield(request, self)
		
		return if @stream.closed?
		
		if response
			write_response(self.version, response.status, response.headers, response.body)
		else
			# If the request failed to generate a response, it was an internal server error:
			write_response(self.version, 500, {}, nil)
		end
		
		# Gracefully finish reading the request body if it was not already done so.
		request.finish
		
		# This ensures we yield at least once every iteration of the loop and allow other fibers to execute.
		task.yield
	end
end