When a person is imprisoned or detained in custody on any criminal charge, for want of bail, such person is entitled to a writ of habeas corpus for the purpose of giving bail, upon averring that fact in his petition, without alleging that he is illegally confined.
Ca. Pen. Code § 1490