This closes #2043
This commit is contained in:
commit
5daa3769aa
|
@ -31,6 +31,7 @@ import org.apache.activemq.artemis.dto.ComponentDTO;
|
|||
import org.apache.activemq.artemis.dto.WebServerDTO;
|
||||
import org.apache.activemq.artemis.utils.FileUtil;
|
||||
import org.apache.activemq.artemis.utils.TimeUtils;
|
||||
import org.eclipse.jetty.server.ConnectionFactory;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.HttpConfiguration;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
|
@ -81,12 +82,16 @@ public class WebServerComponent implements ExternalComponent {
|
|||
|
||||
HttpConfiguration https = new HttpConfiguration();
|
||||
https.addCustomizer(new SecureRequestCustomizer());
|
||||
https.setSendServerVersion(false);
|
||||
HttpConnectionFactory httpFactory = new HttpConnectionFactory(https);
|
||||
|
||||
connector = new ServerConnector(server, sslConnectionFactory, httpFactory);
|
||||
|
||||
} else {
|
||||
connector = new ServerConnector(server);
|
||||
HttpConfiguration configuration = new HttpConfiguration();
|
||||
configuration.setSendServerVersion(false);
|
||||
ConnectionFactory connectionFactory = new HttpConnectionFactory(configuration);
|
||||
connector = new ServerConnector(server, connectionFactory);
|
||||
}
|
||||
connector.setPort(uri.getPort());
|
||||
connector.setHost(uri.getHost());
|
||||
|
|
|
@ -41,6 +41,7 @@ import io.netty.handler.codec.http.HttpHeaderNames;
|
|||
import io.netty.handler.codec.http.HttpMethod;
|
||||
import io.netty.handler.codec.http.HttpObject;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponse;
|
||||
import io.netty.handler.codec.http.HttpVersion;
|
||||
import io.netty.handler.ssl.SslHandler;
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
@ -110,6 +111,7 @@ public class WebServerComponentTest extends Assert {
|
|||
ch.writeAndFlush(request);
|
||||
assertTrue(latch.await(5, TimeUnit.SECONDS));
|
||||
assertEquals(clientHandler.body, "12345");
|
||||
assertNull(clientHandler.serverHeader);
|
||||
// Wait for the server to close the connection.
|
||||
ch.close();
|
||||
Assert.assertTrue(webServerComponent.isStarted());
|
||||
|
@ -205,6 +207,7 @@ public class WebServerComponentTest extends Assert {
|
|||
ch.writeAndFlush(request);
|
||||
assertTrue(latch.await(5, TimeUnit.SECONDS));
|
||||
assertEquals(clientHandler.body, "12345");
|
||||
assertNull(clientHandler.serverHeader);
|
||||
// Wait for the server to close the connection.
|
||||
ch.close();
|
||||
Assert.assertTrue(webServerComponent.isStarted());
|
||||
|
@ -309,6 +312,7 @@ public class WebServerComponentTest extends Assert {
|
|||
|
||||
private CountDownLatch latch;
|
||||
private String body;
|
||||
private String serverHeader;
|
||||
|
||||
ClientHandler(CountDownLatch latch) {
|
||||
this.latch = latch;
|
||||
|
@ -316,7 +320,10 @@ public class WebServerComponentTest extends Assert {
|
|||
|
||||
@Override
|
||||
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) {
|
||||
if (msg instanceof HttpContent) {
|
||||
if (msg instanceof HttpResponse) {
|
||||
HttpResponse response = (HttpResponse) msg;
|
||||
serverHeader = response.headers().get("Server");
|
||||
} else if (msg instanceof HttpContent) {
|
||||
HttpContent content = (HttpContent) msg;
|
||||
body = content.content().toString(CharsetUtil.UTF_8);
|
||||
latch.countDown();
|
||||
|
|
Loading…
Reference in New Issue