not, however, require the district court to treat it as a section 2241 petition. On the contrary, if an application that should be brought under 28 U.S.C. § 2254 is mislabeled as a petition under section 2241, the district court must treat it as a section 2254 application instead. James v. Walsh, 308 F.3d 162, 166 (2d Cir.2002). “[I]t is the substance of the petition, rather than its form, that” governs. Id. The district court correctly treated Cook’s petition as an application under section 2254. By its terms, section 2254 applies to “application[s] ... in behalf of ... a person in custody pursuant to the ju (2d Cir.1999) (per curiam) (noting that a challenge to federal extradition was properly brought under section 2241); Chambers v. United States, 106 F.3d 472, 474-75 (2d Cir.1997) (<HOLDING>). But, as we observed in James, section 2255,
holding that a  2241 petitioners claim was not cognizable under  2241 and therefore the district court lacked jurisdiction holding that a defendant is not entitled to credit for time served as a condition of probation holding that credit cannot be awarded for time served on community control holding that a petition relating to calculation of credit for time served during federal detention was properly brought under section 2241 recognizing our ability to construe a pretrial habeas petition filed under  2254 as being brought under  2241