[SPARK-2750] support https in spark web ui

https://issues.apache.org/jira/browse/SPARK-2750

enable spark web ui to support https, also compatible with old web ui(http).

user can switch between https and http by configure "spark.http.policy".
Hi @scwf,

The reason I asked for a comment is that it seems like the method is doing a little more than just that. For example, L238 seems to be doing some sort of parsing of the `server` string, so it's more than just concatenating the different arguments into a URL.

It would be nice if the comment explained exactly what the relationship between the input and the output is. A unit test wouldn't hurt either.