I read a detective story when I was a kid but can't find I now.
The protagonist confessed to a murder he didn't commit to protect a client of his detective agency (who did). However, he carefully planned his arrest and confession ahead and used a legal loophole which let him avoid standing trial, so he had to be released.
- The loophole had something to do with the extradition laws between two different US states (I think they were Nevada and Utah).
- The protagonist was arrested for something else than the murder.
- The protagonist had the sheriff drag him into the police car kicking and screaming and then used this fact when making his case.
The rest of the details I remember:
- It was (I think) an English-language story, I read it in Russian translation.
- It was set in the US, first part of the XX century.
- It was (again, I think) the first part of a series.
- The protagonist was employed in a private detective agency run by a fat woman. At one point the protagonist was talking about his employer on the phone (as she listened to the conversation) and was hesitant to describe her physical appearance. She encouraged him to go ahead and just tell that she was fat.