@@ -50,6 +50,7 @@ import io.netty.handler.codec.http2.DefaultHttp2DataFrame
50
50
import io.netty.handler.codec.http2.DefaultHttp2GoAwayFrame
51
51
import io.netty.handler.codec.http2.DefaultHttp2Headers
52
52
import io.netty.handler.codec.http2.DefaultHttp2HeadersFrame
53
+ import io.netty.handler.codec.http2.DefaultHttp2PingFrame
53
54
import io.netty.handler.codec.http2.Http2Error
54
55
import io.netty.handler.codec.http2.Http2FrameCodec
55
56
import io.netty.handler.codec.http2.Http2FrameCodecBuilder
@@ -1245,6 +1246,38 @@ class ConnectionManagerSpec extends Specification {
1245
1246
' micronaut.http.client.http2.ping-interval-idle' | true
1246
1247
}
1247
1248
1249
+ def ' http2 server ping' () {
1250
+ given :
1251
+ def ctx = ApplicationContext . run([
1252
+ ' micronaut.http.client.ssl.insecure-trust-all-certificates' : true ,
1253
+ ' spec.name' : ConnectionManagerSpec . simpleName,
1254
+ ])
1255
+ def client = ctx. getBean(DefaultHttpClient )
1256
+
1257
+ def conn = new EmbeddedTestConnectionHttp2 ()
1258
+ conn. setupHttp2Tls()
1259
+ patch(client, conn)
1260
+
1261
+ def future = conn. testExchangeRequest(client)
1262
+ conn. exchangeSettings()
1263
+ conn. testExchangeResponse(future)
1264
+
1265
+ assertPoolConnections(client, 1 )
1266
+
1267
+ conn. serverChannel. writeAndFlush(new DefaultHttp2PingFrame (123 ))
1268
+ conn. advance()
1269
+
1270
+ expect :
1271
+ def pong = conn. serverChannel. readInbound()
1272
+ pong instanceof Http2PingFrame
1273
+ pong. ack
1274
+ pong. content == 123
1275
+
1276
+ cleanup :
1277
+ client. close()
1278
+ ctx. close()
1279
+ }
1280
+
1248
1281
void assertPoolConnections (DefaultHttpClient client , int count ) {
1249
1282
assert client. connectionManager. getChannels(). size() == count
1250
1283
client. connectionManager. getChannels(). forEach { assert it. isActive() }
0 commit comments