46-30-217. Rights of accused persons -- habeas corpus. (1) A person arrested upon a warrant pursuant to this chapter may not be delivered over to the agent whom the executive authority demanding the person has appointed to receive the person unless the person is first taken without delay before a judge of a court of record in this state, who shall inform the person of the demand made for the person's surrender and of the crime with which the person is charged and that the person has the right to demand and procure legal counsel.
(2) If the prisoner or the prisoner's counsel states that the prisoner or the prisoner and counsel desire to test the legality of the prisoner's arrest, the judge of the court of record shall fix a reasonable time to be allowed the prisoner within which to apply for a writ of habeas corpus. When the writ is applied for, notice of the writ and of the time and place of hearing on the writ must be given to the prosecuting officer of the county in which the arrest was made and in which the accused is in custody and to the agent of the demanding state.