The court or judge before whom the petitioner is brought,
after hearing the matter both upon the return and any other
evidence, shall either discharge or remand him, or admit him to
bail, as may be proper, and adjudge the costs of the proceedings,
including the charge for transporting the prisoner, to be paid as
shall seem to be right.