[TS-3121] : Prevent sending HEAD_DONE incorrectly when there's an error in http layer