Skip to content

Commit 6873522

Browse files
committed
fix batch 2
1 parent b5fae19 commit 6873522

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/main/asciidoc/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Please check the {@link io.vertx.httpproxy.interceptors.BodyTransformer} for oth
178178

179179
==== WebSocket interceptor
180180

181-
You can use WebSocket interceptor to wrap a interceptor to let it allow WebSocket handling:
181+
You can use WebSocket interceptor to wrap an interceptor to let it allow WebSocket handling:
182182

183183
[source,java]
184184
----

src/test/java/io/vertx/tests/WebSocketCacheTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public void testWsWithCache(TestContext ctx) {
3737
latch.complete();
3838
}));
3939
});
40-
ws2.write(Buffer.buffer("v2"));
40+
ws2.write(Buffer.buffer("v2")); // second WebSocket, send and reply "v2"
4141
}));
4242
}));
4343
});
44-
ws1.write(Buffer.buffer("v1"));
44+
ws1.write(Buffer.buffer("v1")); // first WebSocket, send and reply "v1"
4545
}));
4646
}
4747
}

src/test/java/io/vertx/tests/interceptors/WebSocketInterceptorTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ private SocketAddress backend(TestContext ctx, Async async) {
4040
});
4141
}
4242

43+
/**
44+
* The interceptor adds a suffix to the uri. If uri is changed by the interceptor, it calls a hit.
45+
*
46+
* @param ctx the test context
47+
* @param interceptor the added interceptor
48+
* @param httpHit if interceptor changes the regular HTTP packet
49+
* @param wsHit if interceptor changes the WebSocket packet
50+
*/
4351
private void testWithInterceptor(TestContext ctx, ProxyInterceptor interceptor, boolean httpHit, boolean wsHit) {
4452
Async latch = ctx.async(4);
4553
SocketAddress backend = backend(ctx, latch);
@@ -77,18 +85,21 @@ public void testNotInterceptor(TestContext ctx) {
7785

7886
@Test
7987
public void testNotApplySocket(TestContext ctx) {
88+
// this interceptor only applies to regular HTTP traffic
8089
ProxyInterceptor interceptor = PathInterceptor.changePath(x -> x + "/updated");
8190
testWithInterceptor(ctx, interceptor, true, false);
8291
}
8392

8493
@Test
8594
public void testWithSocketInterceptor(TestContext ctx) {
95+
// this interceptor applies to both regular HTTP traffic and WebSocket handshake
8696
ProxyInterceptor interceptor = WebSocketInterceptor.allow(PathInterceptor.changePath(x -> x + "/updated"));
8797
testWithInterceptor(ctx, interceptor, true, true);
8898
}
8999

90100
@Test
91101
public void testOnlyHitSocket(TestContext ctx) {
102+
// this interceptor only applies to WebSocket handshake
92103
ProxyInterceptor interceptor = new ProxyInterceptor() {
93104
@Override
94105
public Future<ProxyResponse> handleProxyRequest(ProxyContext context) {

0 commit comments

Comments
 (0)