Such officer or his underofficer, underkeeper or deputy shall, within three days after the service thereof and upon:
(1) Payment or tender of charges, not exceeding ten cents per mile, of bringing the prisoner, to be ascertained by the judge or court that awarded the writ and endorsed thereon; and(2) Security given by his own bond (a) to pay the charges of carrying back the prisoner, if he shall be remanded by the court or judge to which he shall be brought and (b) that he will not make any escape by the way; Make return of such writ and bring or cause to be brought the body of the person so committed or restrained unto or before the judge or court from whence the writ shall issue or unto and before such other person before whom the writ is made returnable, according to the command thereof, and shall then certify the true cause of his detainer or imprisonment; provided, however, that:
(1) If any prisoner be not able to pay such charges they shall be paid by the county wherein he is confined; and(2) If such prisoner shall be acquitted of the charge against him or finally discharged on habeas corpus by the judge or court hearing the habeas corpus proceedings the expenses of the proceeding in habeas corpus shall be paid by the county in which the case is situated.1870 (14) 400; R. S. 95; G. S. 2328; Cr. C. '02 Section 95; Cr. C. '12 Section 122; Cr. P. '22 Section 140; 1932 Code Section 1053; 1942 Code Section 1053; 1952 Code Section 17-357; 1962 Code Section 17-357.