The officer charged with the execution of the warrant shall bring the persons therein mentioned before the judge or court issuing the same, who shall inquire into the cause of the imprisonment or restraint, and make an order thereon, as in cases of habeas corpus, either remanding into custody, discharging or admitting to bail the party so imprisoned or restrained.