imrpove onPreEnd method, fix res err catch, fix response redirecting