No person who has been discharged by order of the court on a habeas corpus, shall be again imprisoned, restrained or kept in custody for the same cause, unless he or she is afterwards indicted for the same offense, nor unless by the legal order or process of the court wherein he or she is bound by recognizance to appear. The following shall not be deemed to be the same cause:
1.If, after a discharge for a defect of proof, or any material defect in the commitment, in a criminal case, the prisoner is again arrested on sufficient proof, and committed by legal process for the same offense.2.If, in a civil action, the party has been discharged for any illegality in the judgment or process, and is afterwards imprisoned by legal process for the same cause of action.3.Generally, whenever the discharge is ordered on account of the non-observance of any of the forms required by law, the party may be a second time imprisoned if the cause is legal and the forms required by law observed.