The officer or person executing the governor's warrant of arrest or the agent of the demanding state to whom the prisoner may have been delivered may, when necessary, confine the prisoner in the jail of any county or city through which the prisoner may pass. The keeper of the county or city jail must receive and safely keep the prisoner until the person having charge of the prisoner is ready to proceed on the person's route, that person being chargeable with the expense of keeping.