fixed request encoding issue and refactored request.toString().