public static String normalizeUrl(String requestUrl) throws AuthException {
    URI uri;
    try {
      uri = new URI(requestUrl);
    } catch (URISyntaxException ex) {
      throw new AuthException(ex);
    }
    String scheme = uri.getScheme();
    String authority = uri.getAuthority();
    if (scheme == null || authority == null) {
      throw new AuthException("Invalid requestUrl [" + requestUrl + "].");
    }
    scheme = scheme.toLowerCase();
    authority = authority.toLowerCase();

    if (("http".equals(scheme) && uri.getPort() == 80)
        || ("https".equals(scheme) && uri.getPort() == 443)) {
      int colonIndex = authority.indexOf(":");
      if (colonIndex > 0) {
        authority = authority.substring(0, colonIndex);
      }
    }
    String path = uri.getRawPath();
    if (path == null || path.length() == 0) {
      path = "/";
    }

    return scheme + "://" + authority + path;
  }
public static String normalizeUrl ( String requestUrl ) throws AuthException { URI uri ; try { uri = new URI ( requestUrl ) ; } catch ( URISyntaxException ex ) { throw new AuthException ( ex ) ; } String scheme = uri . getScheme ( ) ; String authority = uri . getAuthority ( ) ; if ( scheme == null || authority == null ) { throw new AuthException ( "Invalid requestUrl [" + requestUrl + "]." ) ; } scheme = scheme . toLowerCase ( ) ; authority = authority . toLowerCase ( ) ; if ( ( "http" . equals ( scheme ) && uri . getPort ( ) == 80 ) || ( "https" . equals ( scheme ) && uri . getPort ( ) == 443 ) ) { int colonIndex = authority . indexOf ( ":" ) ; if ( colonIndex > 0 ) { authority = authority . substring ( 0 , colonIndex ) ; } } String path = uri . getRawPath ( ) ; if ( path == null || path . length ( ) == 0 ) { path = "/" ; } return scheme + "://" + authority + path ; }
Returns a normalized request uri. The scheme, authority, and path
of the request resource uri [rfc 3986] are included by constructing
an "http" or "https" uri representing the request resource
(without the query or fragment).

@see <a href="http://tools.ietf.org/html/rfc5849#section-3.4.1">3.4.1.2. Base String URI</a>

@param requestUrl request url
@return the normalized request uri
@throws AuthException if the <code>requestUrl</code> violates rfc 2396