Refactors choosing resource and getting bytes in responsebuilder