diff --git a/codec-http/pom.xml b/codec-http/pom.xml
index c1ae7cef75..fee59284b7 100644
--- a/codec-http/pom.xml
+++ b/codec-http/pom.xml
@@ -34,6 +34,11 @@
netty-codec
${project.version}
+
+ ${project.groupId}
+ netty-handler
+ ${project.version}
+
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshakeHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshakeHandler.java
index 0fa6de826f..ad14917bb1 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshakeHandler.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshakeHandler.java
@@ -23,10 +23,12 @@ import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
+import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.http.DefaultHttpResponse;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpResponse;
+import io.netty.handler.ssl.SslHandler;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
@@ -55,7 +57,7 @@ class WebSocketServerHandshakeHandler extends ChannelInboundMessageHandlerAdapte
}
final WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(
- getWebSocketLocation(req, websocketPath), subprotocols, allowExtensions);
+ getWebSocketLocation(ctx.pipeline(), req, websocketPath), subprotocols, allowExtensions);
final WebSocketServerHandshaker handshaker = wsFactory.newHandshaker(req);
if (handshaker == null) {
wsFactory.sendUnsupportedWebSocketVersionResponse(ctx.channel());
@@ -88,8 +90,13 @@ class WebSocketServerHandshakeHandler extends ChannelInboundMessageHandlerAdapte
}
}
- private static String getWebSocketLocation(HttpRequest req, String path) {
- return "ws://" + req.getHeader(HttpHeaders.Names.HOST) + path;
+ private static String getWebSocketLocation(ChannelPipeline cp, HttpRequest req, String path) {
+ String protocol = "ws";
+ if (cp.get(SslHandler.class) != null) {
+ // SSL in use so use Secure WebSockets
+ protocol = "wss";
+ }
+ return protocol + "://" + req.getHeader(HttpHeaders.Names.HOST) + path;
}
}