code: public static String getAuthority(SlingHttpServletRequest request) {
          String host = request.getServerName();
          int port = request.getServerPort();
          return port > 0 && (port != getDefaultPort(request)) ? (host + ":" + port) : host;
      }
docs: Builds the 'authority' part (host:port) of an absolute URL.
  
  @param request the current request with the 'host' and 'port' values