refactor http request to be more concise, hopefully it is still clear.