If a prisoner taken before a judge pursuant to § 23-24-11 or his counsel shall state that he or they desire to test the legality of his arrest, the judge of such court of record shall fix a reasonable time to be allowed him within which to apply for a writ of habeas corpus. When such writ is applied for, notice thereof, and of the time and place of hearing thereon, shall be given to the prosecuting officer of the county in which the arrest is made and in which the accused is in custody, and to the said agent of the demanding state.
SDCL 23-24-12