No complainant or witness on his way to any court shall be required to accompany a police officer, or shall be subject to unnecessary restraint or inconvenience, or required to give any security for his appearance other than his own bond:
Provided that, if, any complainant or witness refuses to attend or to execute a bond as directed in section 170, the officer in charge of the police station may forward him in custody to the Magistrate, who may detain him in custody until he executes such bond, or until the hearing, of the case is completed.