When the person who applies for a writ of habeas corpus shall not be in the custody of a jailor or other officer, the judge may, for good cause shown, direct the officer or person serving the writ to take the applicant into his or her custody and produce him or her on the return of the writ.