Effector function prior to establishment of the pathogen niche is required for protective CD4+ T cell-mediated immunity