|
39 | 39 | import io.netty.handler.codec.http2.Http2Exception; |
40 | 40 | import io.netty.handler.codec.http2.Http2Flags; |
41 | 41 | import io.netty.handler.codec.http2.Http2FrameAdapter; |
| 42 | +import io.netty.handler.codec.http2.Http2FrameListener; |
42 | 43 | import io.netty.handler.codec.http2.Http2Headers; |
43 | 44 | import io.netty.handler.codec.http2.Http2Settings; |
44 | 45 | import io.netty.handler.codec.http2.Http2Stream; |
@@ -1278,6 +1279,27 @@ public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promi |
1278 | 1279 | await(); |
1279 | 1280 | } |
1280 | 1281 |
|
| 1282 | + @Test |
| 1283 | + public void testHostHeaderInsteadOfAuthorityPseudoHeader() throws Exception { |
| 1284 | + // build the HTTP/2 headers, omit the ":authority" pseudo-header and include the "host" header instead |
| 1285 | + Http2Headers headers = new DefaultHttp2Headers().method("GET").scheme("https").path("/").set("host", DEFAULT_HTTPS_HOST_AND_PORT); |
| 1286 | + server.requestHandler(req -> { |
| 1287 | + // validate that the authority is properly populated |
| 1288 | + assertEquals(DEFAULT_HTTPS_HOST, req.authority().host()); |
| 1289 | + assertEquals(DEFAULT_HTTPS_PORT, req.authority().port()); |
| 1290 | + testComplete(); |
| 1291 | + }); |
| 1292 | + startServer(); |
| 1293 | + TestClient client = new TestClient(); |
| 1294 | + ChannelFuture fut = client.connect(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, request -> { |
| 1295 | + int id = request.nextStreamId(); |
| 1296 | + Http2ConnectionEncoder encoder = request.encoder; |
| 1297 | + encoder.writeHeaders(request.context, id, headers, 0, true, request.context.newPromise()); |
| 1298 | + }); |
| 1299 | + fut.sync(); |
| 1300 | + await(); |
| 1301 | + } |
| 1302 | + |
1281 | 1303 | @Test |
1282 | 1304 | public void testMissingMethodPseudoHeader() throws Exception { |
1283 | 1305 | testMalformedRequestHeaders(new DefaultHttp2Headers().scheme("http").path("/")); |
|
0 commit comments