code: public static String getScheme(HttpServletRequest request) {
  
  		String scheme = request.getHeader("X-Forwarded-Proto");
  		if (StringUtils.isNullOrEmptyTrimmed(scheme)) {
  			scheme = request.getScheme();
  		}
  
  		return scheme != null ? scheme.trim().toLowerCase() : null;
  	}
docs: see: http://stackoverflow.com/questions/19598690/how-to-get-host-name-with-port-from-a-http-or-https-request/19599143#19599143
  takes into account that request might go through a reverse proxy and request.getScheme() might not be correct
  
  @param request request
  @return scheme (http, https ...)