Correctly build socketaddress string, followup of 8b2badf44f

This commit is contained in:
Norman Maurer 2017-03-01 20:05:00 +01:00
parent 0514b0c61b
commit 1392bc351f
2 changed files with 2 additions and 3 deletions

View File

@ -37,7 +37,6 @@ import io.netty.util.NetUtil;
import io.netty.util.ReferenceCountUtil; import io.netty.util.ReferenceCountUtil;
import io.netty.util.internal.ThrowableUtil; import io.netty.util.internal.ThrowableUtil;
import java.net.InetSocketAddress;
import java.net.URI; import java.net.URI;
import java.nio.channels.ClosedChannelException; import java.nio.channels.ClosedChannelException;
@ -475,7 +474,7 @@ public abstract class WebSocketClientHandshaker {
// if the port is not standard (80/443) its needed to add the port to the header. // if the port is not standard (80/443) its needed to add the port to the header.
// See http://tools.ietf.org/html/rfc6454#section-6.2 // See http://tools.ietf.org/html/rfc6454#section-6.2
return NetUtil.toSocketAddressString(InetSocketAddress.createUnresolved(host, port)); return NetUtil.toSocketAddressString(host, port);
} }
static CharSequence websocketOriginValue(String host, int wsPort) { static CharSequence websocketOriginValue(String host, int wsPort) {

View File

@ -966,7 +966,7 @@ public final class NetUtil {
public static String toSocketAddressString(String host, int port) { public static String toSocketAddressString(String host, int port) {
String portStr = String.valueOf(port); String portStr = String.valueOf(port);
return newSocketAddressStringBuilder( return newSocketAddressStringBuilder(
host, portStr, isValidIpV4Address(host)).append(portStr).toString(); host, portStr, !isValidIpV6Address(host)).append(':').append(portStr).toString();
} }
private static StringBuilder newSocketAddressStringBuilder(String host, String port, boolean ipv4) { private static StringBuilder newSocketAddressStringBuilder(String host, String port, boolean ipv4) {