small code refactor in http client