refactor how headers are set in remotePost