@@ -40,6 +40,14 @@ private SocketAddress backend(TestContext ctx, Async async) {
40
40
});
41
41
}
42
42
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
+ */
43
51
private void testWithInterceptor (TestContext ctx , ProxyInterceptor interceptor , boolean httpHit , boolean wsHit ) {
44
52
Async latch = ctx .async (4 );
45
53
SocketAddress backend = backend (ctx , latch );
@@ -77,18 +85,21 @@ public void testNotInterceptor(TestContext ctx) {
77
85
78
86
@ Test
79
87
public void testNotApplySocket (TestContext ctx ) {
88
+ // this interceptor only applies to regular HTTP traffic
80
89
ProxyInterceptor interceptor = PathInterceptor .changePath (x -> x + "/updated" );
81
90
testWithInterceptor (ctx , interceptor , true , false );
82
91
}
83
92
84
93
@ Test
85
94
public void testWithSocketInterceptor (TestContext ctx ) {
95
+ // this interceptor applies to both regular HTTP traffic and WebSocket handshake
86
96
ProxyInterceptor interceptor = WebSocketInterceptor .allow (PathInterceptor .changePath (x -> x + "/updated" ));
87
97
testWithInterceptor (ctx , interceptor , true , true );
88
98
}
89
99
90
100
@ Test
91
101
public void testOnlyHitSocket (TestContext ctx ) {
102
+ // this interceptor only applies to WebSocket handshake
92
103
ProxyInterceptor interceptor = new ProxyInterceptor () {
93
104
@ Override
94
105
public Future <ProxyResponse > handleProxyRequest (ProxyContext context ) {
0 commit comments