The person alleged to have such party under illegal confinement or restraint may make return to such warrant as in case of a writ of habeas corpus, and the same may be denied, and like allegations, proofs, and trial may thereupon be had as upon a return to a writ of habeas corpus.