/** * Create a canonical URI from a given URI. A canonical URI is a URI with:<ul> <li>the host part of the authority * lower-case since URI semantics dictate that hostnames are case insensitive <li>(optionally, NOT appropriate for Origin * headers) the path part set to "/" if there was no path in the input URI (this conforms to the WebSocket and HTTP protocol * specifications and avoids us having to do special handling for path throughout the server code). </ul> * * @param uriString the URI to canonicalize, in string form * @param canonicalizePath if true, append trailing '/' when missing * @return a URI with the host part of the authority lower-case and (optionally) trailing / added, or null if the uri is null * @throws IllegalArgumentException if the uriString is not valid syntax */ public static String getCanonicalURI(String uriString, boolean canonicalizePath) { if ((uriString != null) && !"".equals(uriString)) { return getCanonicalizedURI(uriString, canonicalizePath); } return null; }
static String getTransportURI(String transportKey, String transport) { String transportURI = null; if (transport != null) { transportURI = transport; if (!URIUtils.isAbsolute(transportURI)) { throw new IllegalArgumentException(format( "%s must contain an absolute URI, not \"%s\"", transportKey, transport)); } transportURI = getCanonicalizedURI(transportURI, false); } return transportURI; }