Helper method for modifying URI port
@param uri
@param newPort
@return
191162
public static String modifyURIPort(String uri, int newPort) {
        try {
            URI uriObj = new URI(uri);
            return uriToString(URLUtils.modifyURIPort(uriObj, newPort));
        }
        catch (URISyntaxException e) {
            try {
                return (new NetworkInterfaceURI(uri)).modifyURIPort(newPort);
            }
            catch (IllegalArgumentException ne) {
                throw new IllegalArgumentException(ne.getMessage(), ne);
            }
        }
    }
693849
public static String newURI(String scheme, String server, int port, String path, String query) {
        StringBuilder builder = newURIBuilder(scheme, server, port);
        builder.append(path);
        if (query != null && query.length() > 0)
            builder.append('?').append(query);
        return builder.toString();
    }
365433
public UriComponentsBuilder port(int port) {
		Assert.isTrue(port >= -1, "'port' must not be < -1");
		this.port = String.valueOf(port);
		resetSchemeSpecificPart();
		return this;
	}
741004
public static WebsocketClientTransport create(URI uri) {
    Objects.requireNonNull(uri, "uri must not be null");

    TcpClient client = createClient(uri);
    return create(HttpClient.from(client), uri.getPath());
  }
117064
public URI getListeningURI() {
    try {
      return new URI(this.serverUri.getScheme(), this.serverUri.getUserInfo(), this.serverUri.getHost(), this.port,
          null, null, null);
    } catch (URISyntaxException use) {
      throw new RuntimeException("Invalid URI. This is an error in code.", use);
    }
  }
1341476
public URI toUri(final String stringUri) {
    try {
      final java.net.URI netUri = new java.net.URI(stringUri);
      return this.toEmfUri(netUri);
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
    }
  }
220270
public static InetSocketAddress toInetSocketAddress(URI uri) {
		final InetAddress adr = toInetAddress(uri);
		final int port = uri.getPort();
		if (port <= 0) {
			throw new IllegalArgumentException(uri.toString());
		}
		return new InetSocketAddress(adr, port);
	}
297203
public static URI urlToURI(URL url) {
    try {
      return url.toURI();
    }
    catch (URISyntaxException e) {
      throw LOG.cannotConvertUrlToUri(url, e);
    }
  }
694191
def port=(new_port)
      if new_port != nil && new_port.respond_to?(:to_str)
        new_port = Addressable::URI.unencode_component(new_port.to_str)
      end

      if new_port.respond_to?(:valid_encoding?) && !new_port.valid_encoding?
        raise InvalidURIError, "Invalid encoding in port"
      end

      if new_port != nil && !(new_port.to_s =~ /^\d+$/)
        raise InvalidURIError,
          "Invalid port number: #{new_port.inspect}"
      end

      @port = new_port.to_s.to_i
      @port = nil if @port == 0

      # Reset dependent values
      remove_instance_variable(:@authority) if defined?(@authority)
      remove_instance_variable(:@normalized_port) if defined?(@normalized_port)
      remove_composite_values

      # Ensure we haven't created an invalid URI
      validate()
    end
1295570
private HttpUriRequest makeRequest(final URI uri, final List<NameValuePair> nvpairs)
    {
        List<NameValuePair> params = nvpairs;
        if (m_secret != null) {
            params = sign(uri, nvpairs);
        }
        return makeRequest(uri, joinParameters(params));
    }
533213
public static URI toUri(String endpoint, Protocol protocol) {
        if (endpoint == null) {
            throw new IllegalArgumentException("endpoint cannot be null");
        }

        /*
         * If the endpoint doesn't explicitly specify a protocol to use, then
         * we'll defer to the default protocol specified in the client
         * configuration.
         */
        if (!endpoint.contains("://")) {
            endpoint = protocol.toString() + "://" + endpoint;
        }

        try {
            return new URI(endpoint);
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException(e);
        }
    }
76431
public static String findURITransport(URI uri, int messageContentLength) {
		String transport = ListeningPoint.UDP;
		if(uri instanceof SipURI) {
			SipURI sipURI = (SipURI) uri;
			if(sipURI.isSecure()) {
				transport = ListeningPoint.TLS;
			} else {
				String transportParam = sipURI.getTransportParam();

				if (transportParam != null
						&& transportParam.equalsIgnoreCase(ListeningPoint.TLS)) {
					transport = ListeningPoint.TLS;
				} // 
				else if (transportParam != null
						&& transportParam.equalsIgnoreCase(ListeningPointExt.WS)) {
					transport = ListeningPointExt.WS;
				} else if (transportParam != null
						&& transportParam.equalsIgnoreCase(ListeningPointExt.WSS)) {
					transport = ListeningPointExt.WSS;
				}
				// moved TCP at the bottom to avoid having TCP being chosen because of message Content Length being too big for WebRTC
				//Fix by Filip Olsson for Issue 112
				else if ((transportParam != null
						&& transportParam.equalsIgnoreCase(ListeningPoint.TCP)) || 
						messageContentLength > 4096) {
					transport = ListeningPoint.TCP;
				} 
				
			}
		}
		return transport;
	}
459755
public void setDestinationUri(URI uri) {
        if (EventUtils.isEmptyOrNull(uri)) {
            LOGGER.error("The destination URI cannot be null");
            throw new IllegalArgumentException("The destination URI cannot be null");
        }

        // Try determining the host address
        InetAddress address;
        try {
            address = InetAddress.getByName(uri.getHost());
        } catch (Exception e) {
            LOGGER.error("The specified address could not be resolved");
            throw new IllegalArgumentException("The specified address could not be resolved");
        }

        setDestinationAddress(address);

        // Try determining the port
        int port = uri.getPort();
        if (port == -1) {
            LOGGER.warn("Invalid port specified in URI, using transport default port");
            port = AuditorModuleConfig.AUDITOR_AUDIT_REPOSITORY_DEFAULT_PORT;
        }

        setDestinationPort(port);
    }
629653
function callUri(uri) {
  var iframe = document.createElement('iframe');
  iframe.src = uri;
  iframe.style.display = 'none';
  document.documentElement.appendChild(iframe);
  setTimeout(function () {
    return document.documentElement.removeChild(iframe);
  }, 0);
}
866142
private URI serviceUri(Channel channel, MethodDescriptor<?, ?> method) throws StatusException {
    String authority = channel.authority();
    if (authority == null) {
      throw Status.UNAUTHENTICATED.withDescription("Channel has no authority").asException();
    }
    // Always use HTTPS, by definition.
    final String scheme = "https";
    final int defaultPort = 443;
    String path = "/" + method.getServiceName();
    URI uri;
    try {
      uri = new URI(scheme, authority, path, null, null);
    } catch (URISyntaxException e) {
      throw Status.UNAUTHENTICATED.withDescription("Unable to construct service URI for auth")
          .withCause(e).asException();
    }
    // The default port must not be present. Alternative ports should be present.
    if (uri.getPort() == defaultPort) {
      uri = removePort(uri);
    }
    return uri;
  }
133170
def port_uris_prop(self):
        
        if self._port_uris_prop is None:
            family = self.get_property('adapter-family')
            try:
                self._port_uris_prop = self.port_uris_prop_by_family[family]
            except KeyError:
                self._port_uris_prop = ''
        return self._port_uris_prop
638611
private String convertURItoURL(String uri) {
        int indexScheme = uri.indexOf("://");
        if (-1 != indexScheme) {
            int indexQuery = uri.indexOf('?');
            if (-1 == indexQuery || indexScheme < indexQuery) {
                // already a full url
                return uri;
            }
        }
        StringBuilder sb = new StringBuilder();
        String scheme = this.request.getScheme();
        sb.append(scheme).append("://");
        sb.append(this.request.getServerName());
        int port = this.request.getServerPort();
        if ("http".equalsIgnoreCase(scheme) && 80 != port) {
            sb.append(':').append(port);
        } else if ("https".equalsIgnoreCase(scheme) && 443 != port) {
            sb.append(':').append(port);
        }
        String data = this.request.getContextPath();
        if (!"".equals(data)) {
            sb.append(data);
        }
        if (0 == uri.length()) {
            sb.append('/');
        } else if (uri.charAt(0) == '/') {
            // relative to servlet container root...
            sb.append(uri);
        } else {
            // relative to current URI,
            data = this.request.getServletPath();
            if (!"".equals(data)) {
                sb.append(data);
            }
            data = this.request.getPathInfo();
            if (null != data) {
                sb.append(data);
            }
            sb.append('/');
            sb.append(uri);
            // TODO: webcontainer converted "/./" and "/../" info too
        }

        return sb.toString();
    }