move body parser logic into a function so users can override

see issue #988.