The Supreme Court, and Criminal Court of Appeals and district and superior courts within this state, or the judges thereof in vacation, shall have power to issue writs of habeas corpus, for the purpose of bringing the body of any person confined in any prison before them, to testify or be surrendered in discharge of bail. When a writ of habeas corpus shall be issued for the purpose of bringing into court any person to testify, or the principal, to be surrendered in discharge of bail, and such principal or witness, shall be confined in any prison in this state, out of the county in which such principal or witness is required to be surrendered, or to any county in this state, and there be executed and returned by any officer to whom it shall be directed, and the principal, after being surrendered, or his bail discharged, or a person testifying as aforesaid, shall by the officer executing such writ, be returned by virtue of an order of the court, for the purpose aforesaid, an attested copy of which, lodged with the custodian, shall exonerate such prison keeper from being liable for an escape. The party praying out such writ of habeas corpus shall pay to the officer executing the same, such reasonable sum for his services as shall be adjudged by the courts respectively.
R.L.1910, § 6102.