The writ shall be directed to the person in whose custody the petitioner is detained and made returnable as soon as may be. If the writ be ordered by any court or judge other than the Supreme Court of Appeals or a judge thereof, it shall be returnable before the court or judge ordering it, if such court or judge be of the county wherein the petitioner is detained; otherwise, before a proper court or judge of the county wherein the petitioner is detained. If the writ be ordered by the Supreme Court of Appeals or a judge thereof, it may be made returnable either before such court or before a proper court or judge of the county wherein the petitioner is detained.