org.glassfish.tyrus.core.Utils.getWsPort()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(68)

本文整理了Java中org.glassfish.tyrus.core.Utils.getWsPort()方法的一些代码示例,展示了Utils.getWsPort()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.getWsPort()方法的具体详情如下:
包路径:org.glassfish.tyrus.core.Utils
类名称:Utils
方法名:getWsPort

Utils.getWsPort介绍

[英]Get port from provided URI.

Expected schemes are "ws" and "wss" and this method will return 80 or 443 when the port is not explicitly set in the provided URI.
[中]从提供的URI获取端口。
预期的方案是“ws”和“wss”,当端口未在提供的URI中显式设置时,此方法将返回80或443。

代码示例

代码示例来源:origin: org.glassfish.tyrus/tyrus-core

/**
 * Get port from provided {@link URI}.
 * <p>
 * Expected schemes are {@code "ws"} and {@code "wss"} and this method will return {@code 80} or
 * {@code 443} when the port is not explicitly set in the provided {@link URI}.
 *
 * @param uri provided uri.
 * @return port number which should be used for creating connections/etc.
 */
public static int getWsPort(URI uri) {
  return getWsPort(uri, uri.getScheme());
}

代码示例来源:origin: eclipse-ee4j/tyrus

/**
 * Get port from provided {@link URI}.
 * <p>
 * Expected schemes are {@code "ws"} and {@code "wss"} and this method will return {@code 80} or
 * {@code 443} when the port is not explicitly set in the provided {@link URI}.
 *
 * @param uri provided uri.
 * @return port number which should be used for creating connections/etc.
 */
public static int getWsPort(URI uri) {
  return getWsPort(uri, uri.getScheme());
}

代码示例来源:origin: eclipse-ee4j/tyrus

@Override
public String getRequestUri() {
  final int requestPort = Utils.getWsPort(uri);
  return String.format("%s:%d", uri.getHost(), requestPort);
}

代码示例来源:origin: eclipse-ee4j/tyrus

private SocketAddress getServerAddress(URI uri) throws DeploymentException {
  int port = Utils.getWsPort(uri);
  try {
    return new InetSocketAddress(uri.getHost(), port);
  } catch (IllegalArgumentException e) {
    throw new DeploymentException(e.getMessage(), e);
  }
}

代码示例来源:origin: eclipse-ee4j/tyrus

int port = Utils.getWsPort(uri);
if (LOGGER.isLoggable(Level.FINE)) {
  LOGGER.log(Level.FINE, String.format("Not using proxy for URI '%s'.", uri));

代码示例来源:origin: org.glassfish.tyrus/tyrus-container-grizzly-client

int port = Utils.getWsPort(uri);
if (LOGGER.isLoggable(Level.FINE)) {
  LOGGER.log(Level.FINE, String.format("Not using proxy for URI '%s'.", uri));

代码示例来源:origin: org.glassfish.tyrus/tyrus-client

scheme = "wss";
int port = Utils.getWsPort(location, scheme);
location = new URI(scheme, location.getUserInfo(), location.getHost(), port, location
    .getPath(), location.getQuery(), location.getFragment());

代码示例来源:origin: eclipse-ee4j/tyrus

scheme = "wss";
int port = Utils.getWsPort(location, scheme);
location = new URI(scheme, location.getUserInfo(), location.getHost(), port, location
    .getPath(), location.getQuery(), location.getFragment());

代码示例来源:origin: org.glassfish.tyrus/tyrus-container-grizzly-client

case DIRECT:
  try {
    connectAddress = new InetSocketAddress(requestURI.getHost(), Utils.getWsPort(requestURI));
  } catch (IllegalArgumentException e) {
    closeTransport(privateTransport);

代码示例来源:origin: eclipse-ee4j/tyrus

case DIRECT:
  try {
    connectAddress = new InetSocketAddress(requestURI.getHost(), Utils.getWsPort(requestURI));
  } catch (IllegalArgumentException e) {
    closeTransport(privateTransport);

代码示例来源:origin: eclipse-ee4j/tyrus

private NextAction sendRequest(FilterChainContext ctx, UpgradeRequest upgradeRequest) {
  HttpRequestPacket.Builder builder = HttpRequestPacket.builder();
  if (proxy && !PROXY_CONNECTED.get(ctx.getConnection())) {
    UPGRADE_REQUEST.set(ctx.getConnection(), upgradeRequest);
    URI requestURI = upgradeRequest.getRequestURI();
    final int requestPort = Utils.getWsPort(requestURI);
    builder = builder.uri(String.format("%s:%d", requestURI.getHost(), requestPort));
    builder = builder.protocol(Protocol.HTTP_1_1);
    builder = builder.method(Method.CONNECT);
    if (proxyHeaders != null && proxyHeaders.size() > 0) {
      for (Map.Entry<String, String> entry : proxyHeaders.entrySet()) {
        builder.header(entry.getKey(), entry.getValue());
      }
    }
    builder = builder.header(Header.Host, requestURI.getHost());
    builder = builder.header(Header.ProxyConnection, "keep-alive");
    builder = builder.header(Header.Connection, "keep-alive");
    ctx.write(HttpContent.builder(builder.build()).build());
    ctx.flush(null);
  } else {
    ctx.write(getHttpContent(upgradeRequest));
  }
  // call the next filter in the chain
  return ctx.getInvokeAction();
}

代码示例来源:origin: org.glassfish.tyrus/tyrus-container-grizzly-client

private NextAction sendRequest(FilterChainContext ctx, UpgradeRequest upgradeRequest) {
  HttpRequestPacket.Builder builder = HttpRequestPacket.builder();
  if (proxy && !PROXY_CONNECTED.get(ctx.getConnection())) {
    UPGRADE_REQUEST.set(ctx.getConnection(), upgradeRequest);
    URI requestURI = upgradeRequest.getRequestURI();
    final int requestPort = Utils.getWsPort(requestURI);
    builder = builder.uri(String.format("%s:%d", requestURI.getHost(), requestPort));
    builder = builder.protocol(Protocol.HTTP_1_1);
    builder = builder.method(Method.CONNECT);
    if (proxyHeaders != null && proxyHeaders.size() > 0) {
      for (Map.Entry<String, String> entry : proxyHeaders.entrySet()) {
        builder.header(entry.getKey(), entry.getValue());
      }
    }
    builder = builder.header(Header.Host, requestURI.getHost());
    builder = builder.header(Header.ProxyConnection, "keep-alive");
    builder = builder.header(Header.Connection, "keep-alive");
    ctx.write(HttpContent.builder(builder.build()).build());
    ctx.flush(null);
  } else {
    ctx.write(getHttpContent(upgradeRequest));
  }
  // call the next filter in the chain
  return ctx.getInvokeAction();
}

相关文章