refactor($http): avoid using closure vars in serverRequest fn

The `serverRequest` function was accessing the `headers` var defined in a closure and "reusing" it as a local variable thus making the closure scope bigger and using the same name for 2 different purposes. Hopefully this version of the code is easier to follow.