When a person is imprisoned or detained in custody on any criminal charge for want of bail, such person shall be entitled to a writ of habeas corpus for the purpose of giving bail, upon averring that fact in his petition and without alleging that he is illegally confined. The court or judge may take a recognizance from such person as in other cases and file the recognizance in the proper court without delay.
A.R.S. § 13-4135