before this change, this logic was duplicated in ContinuationInputStream and also readHeaders