Reusable server url

Improve the re-usability of the addQueryArg() method

- Support SSL protocol
- Make the serverUrl code re-usable
Again, the two above lines should be one line.