De-duplicated the logic that creates request headers