[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".
Similarly, this function is only called from one place and it's kind of confusing, so I'd prefer to inline this code in `newURI` (or define it as a nested block / function there).