Skip to content

Commit

Permalink
Merge pull request #139 from chonton/rfc7230
Browse files Browse the repository at this point in the history
  • Loading branch information
cescoffier authored Nov 14, 2023
2 parents d548928 + 739d82a commit 805bb3f
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.vertx.core.Handler;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.http.ServerWebSocket;
import io.vertx.core.http.impl.Http1xServerConnection;
import io.vertx.core.net.impl.ConnectionBase;
import io.vertx.ext.auth.User;
Expand Down Expand Up @@ -109,22 +110,16 @@ public void setResponseHeader(final CharSequence headerName, final String header

@Override
public void upgradeChannel(Consumer<Object> listener) {
response.headers().set(HttpHeaderNames.CONNECTION, "upgrade");

Http1xServerConnection connection = (Http1xServerConnection) request.connection();
ChannelHandlerContext context = connection.channelHandlerContext();
final ChannelHandler websocketChannelHandler = context.pipeline().get("webSocketExtensionHandler");
if (websocketChannelHandler != null) {
context.pipeline().remove(websocketChannelHandler);
}

response.setStatusCode(101).end(new Handler<AsyncResult<Void>>() {
request.toWebSocket().onSuccess(new Handler<ServerWebSocket>() {
@Override
public void handle(AsyncResult<Void> event) {
Http1xServerConnection connection = (Http1xServerConnection) request.connection();
ChannelHandlerContext context = connection.channelHandlerContext();
context.pipeline().remove("httpDecoder");
context.pipeline().remove("httpEncoder");
public void handle(ServerWebSocket ws) {
context.pipeline().remove("handler");
listener.accept(context);
}
Expand Down

0 comments on commit 805bb3f

Please sign in to comment.