Skip to content

Commit 95c967f

Browse files
authored
Use canUpgradeToWebsocket method of Vert.x core (#63)
Fixes #62 Follows-up on eclipse-vertx/vert.x#5098 Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
1 parent 7a139fc commit 95c967f

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

src/main/java/io/vertx/httpproxy/impl/ReverseProxy.java

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,14 @@
1212

1313
import io.vertx.core.Future;
1414
import io.vertx.core.Promise;
15-
import io.vertx.core.http.HttpClient;
16-
import io.vertx.core.http.HttpClientRequest;
17-
import io.vertx.core.http.HttpClientResponse;
18-
import io.vertx.core.http.HttpHeaders;
19-
import io.vertx.core.http.HttpMethod;
20-
import io.vertx.core.http.HttpServerRequest;
21-
import io.vertx.core.http.HttpServerResponse;
22-
import io.vertx.core.http.HttpVersion;
23-
import io.vertx.core.http.RequestOptions;
15+
import io.vertx.core.http.*;
2416
import io.vertx.core.net.NetSocket;
25-
import io.vertx.core.net.SocketAddress;
26-
import io.vertx.httpproxy.HttpProxy;
27-
import io.vertx.httpproxy.ProxyContext;
28-
import io.vertx.httpproxy.ProxyInterceptor;
29-
import io.vertx.httpproxy.ProxyOptions;
30-
import io.vertx.httpproxy.ProxyRequest;
31-
import io.vertx.httpproxy.ProxyResponse;
17+
import io.vertx.httpproxy.*;
3218
import io.vertx.httpproxy.cache.CacheOptions;
3319
import io.vertx.httpproxy.spi.cache.Cache;
3420

35-
import java.util.ArrayList;
36-
import java.util.HashMap;
37-
import java.util.List;
38-
import java.util.ListIterator;
39-
import java.util.Map;
21+
import java.util.*;
4022
import java.util.function.BiFunction;
41-
import java.util.function.Function;
4223

4324
public class ReverseProxy implements HttpProxy {
4425

@@ -82,10 +63,7 @@ public void handle(HttpServerRequest request) {
8263
}
8364

8465
// WebSocket upgrade tunneling
85-
if (supportWebSocket &&
86-
request.version() == HttpVersion.HTTP_1_1 &&
87-
request.method() == HttpMethod.GET &&
88-
request.headers().contains(HttpHeaders.CONNECTION, HttpHeaders.UPGRADE, true)) {
66+
if (supportWebSocket && io.vertx.core.http.impl.HttpUtils.canUpgradeToWebSocket(request)) {
8967
handleWebSocketUpgrade(proxyRequest);
9068
return;
9169
}

0 commit comments

Comments
 (0)