refactor($http): avoid re-creating execHeaders function

The execHeaders function was being re-defined inside mergeHeaders
function. Additionally it was mutating its arguments.

Closes #10359