static void handleWebSocketHandshakeComplete(final Channel channel,
      final InetAddress preferredRemoteAddress,
      @Nullable final String userAgentHeader,
      @Nullable final String acceptLanguageHeader) {

    channel.attr(ClientConnectionManager.REMOTE_ADDRESS_ATTRIBUTE_KEY).set(preferredRemoteAddress);

    if (StringUtils.isNotBlank(userAgentHeader)) {
      channel.attr(ClientConnectionManager.RAW_USER_AGENT_ATTRIBUTE_KEY).set(userAgentHeader);

      try {
        channel.attr(ClientConnectionManager.PARSED_USER_AGENT_ATTRIBUTE_KEY)
            .set(UserAgentUtil.parseUserAgentString(userAgentHeader));
      } catch (final UnrecognizedUserAgentException ignored) {
      }
    }

    if (StringUtils.isNotBlank(acceptLanguageHeader)) {
      try {
        channel.attr(ClientConnectionManager.ACCEPT_LANGUAGE_ATTRIBUTE_KEY).set(Locale.LanguageRange.parse(acceptLanguageHeader));
      } catch (final IllegalArgumentException e) {
        log.debug("Invalid Accept-Language header from User-Agent {}: {}", userAgentHeader, acceptLanguageHeader, e);
      }
    }
  }
@Test
  void handleWebSocketHandshakeCompleteRemoteAddress() {
    final EmbeddedChannel embeddedChannel = new EmbeddedChannel();

    final InetAddress preferredRemoteAddress = InetAddresses.forString("192.168.1.1");

    ClientConnectionManager.handleWebSocketHandshakeComplete(embeddedChannel,
        preferredRemoteAddress,
        null,
        null);

    assertEquals(preferredRemoteAddress,
        embeddedChannel.attr(ClientConnectionManager.REMOTE_ADDRESS_ATTRIBUTE_KEY).get());
  }