@DataProvider(value = {
"80 | false | localhost | localhost",
"80 | true | localhost | localhost:80",
"8080 | false | localhost | localhost:8080",
"443 | true | localhost | localhost",
"443 | false | localhost | localhost:443",
"8080 | true | localhost | localhost:8080",
}, splitBy = "\\|")
@Test
public void streamDownstreamCall_setsHostHeaderCorrectly(int downstreamPort, boolean isSecure, String downstreamHost, String expectedHostHeader) {
DefaultHttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "");
ChannelHandlerContext ctx = mockChannelHandlerContext();
StreamingCallback streamingCallback = mock(StreamingCallback.class);
new StreamingAsyncHttpClient(
200, 200, true, mock(DistributedTracingConfig.class)
).streamDownstreamCall(
downstreamHost, downstreamPort, request, isSecure, false, streamingCallback, 200, true, true, ctx
);
assertThat(request.headers().get(HOST)).isEqualTo(expectedHostHeader);
}