If District magistrate or magistrate of 1st class or sub- divisional magistrate has reason to believe that any person is confined under any circumstances which would be an offence, than he may issue the search warrant for searching of that person. If the person confined founded, he shall be immediately presented before the magistrate, who shall make an order which he thinks proper for the case.
The objective of writ petition of Habeas Corpus and section 97 of criminal procedure code is almost the same. But it seems that people usually neglect to file case under section 97 of Crpc and directly approach the High court and Supreme Court which increase the burden of cases on the court.
Before going to high court or Supreme Court it’s necessary for the party to exhaust all the remedies provided under law. Section 97 of CRPC provides speedy process for releasing of the person detained. Thus it’s necessary in case of detention to approach under section 97 CRPC before filing a writ petition of Habeas corpus. This will release the burden of case on apex court or high courts.