The peace officer to whom the warrant is directed shall execute it by bringing the party named and the person who detains the party, if so commanded by the warrant, before the judge issuing the warrant. The person detaining the party shall make a return to the warrant as in the case of a writ of habeas corpus, and a proceeding shall be had as if a writ of habeas corpus had been issued in the first instance.