Refactor HTTP request body handling to avoid disk writes, closes #1412