moved from client.js to raw httpRequest. Refactoring.