Refactored code related to HTTP message body handling