Every person imprisoned or restrained of liberty by any officer or person, for any cause or under any color or pretense, shall have remedy by the writ of habeas corpus, and may obtain relief, except:
(1) Persons committed or detained on a charge of treason or felony, the species whereof is plainly and fully set forth in the commitment;
(2) Persons convicted of, or charged with, treason, felony, or any offense in another state, who ought, by the Constitution of the United States, to be delivered to the executive of such state, subject to the provisions of § 2510 of Title 11; and
(3) Persons imprisoned by the authority of the United States.