Section 3. The petition for the writ shall be in writing, signed and sworn to by the person for whose release it is intended, or by a person in his behalf, and shall state by whom and where the person is imprisoned or restrained, the name of the prisoner and of the person detaining him, if their names are known, or a description of them, if their names are not known, and the cause or pretence of such imprisonment or restraint, according to the knowledge and belief of the petitioner.
If the imprisonment or restraint is by virtue of a warrant or other process, a copy thereof shall be annexed, unless it appears that such copy has been demanded and refused or that, for a sufficient reason, a demand therefor could not be made.