Section 1. Whoever is imprisoned or restrained of his liberty may, as of right and of course, prosecute a writ of habeas corpus, according to this chapter, to obtain release from such imprisonment or restraint, if it proves to be unlawful, unless?
First, He has been committed for treason or felony, or on suspicion thereof, or as accessory before the fact to a felony, and the cause has been plainly expressed in the warrant of commitment.
Second, He has been convicted or is in execution upon legal process, civil or criminal.
Third, He has been committed on mesne process in a civil action in which he was liable to arrest and imprisonment, unless excessive and unreasonable bail was required.