Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import org.apache.doris.common.Config;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.jetty.ee10.webapp.WebAppContext;
import org.eclipse.jetty.ee10.websocket.server.config.JettyWebSocketServletContainerInitializer;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.ServerConnector;
Expand All @@ -31,10 +35,24 @@

@Configuration
public class WebServerFactoryCustomizerConfig implements WebServerFactoryCustomizer<ConfigurableJettyWebServerFactory> {
private static final Logger LOG = LogManager.getLogger(WebServerFactoryCustomizerConfig.class);

@Override
public void customize(ConfigurableJettyWebServerFactory factory) {

// Set HTTP header size for all connectors
((JettyServletWebServerFactory) factory).addServerCustomizers(server -> {
WebAppContext context = server.getDescendant(WebAppContext.class);
if (context != null) {
try {
JettyWebSocketServletContainerInitializer.configure(context, null);
} catch (Exception e) {
LOG.error("Failed to initialize WebSocket support", e);
throw new RuntimeException("Failed to initialize WebSocket support", e);
}
}
});

factory.addServerCustomizers(server -> {
for (org.eclipse.jetty.server.Connector connector : server.getConnectors()) {
if (connector instanceof ServerConnector) {
Expand All @@ -53,19 +71,18 @@ public void customize(ConfigurableJettyWebServerFactory factory) {
Collections.singletonList(new HttpToHttpsJettyConfig())
);

factory.addServerCustomizers(
server -> {
HttpConfiguration httpConfiguration = new HttpConfiguration();
httpConfiguration.setSecurePort(Config.https_port);
httpConfiguration.setSecureScheme("https");

ServerConnector connector = new ServerConnector(server);
connector.addConnectionFactory(new HttpConnectionFactory(httpConfiguration));
connector.setPort(Config.http_port);

server.addConnector(connector);
factory.addServerCustomizers(server -> {
if (server.getConnectors() != null && server.getConnectors().length > 0) {
ServerConnector existingConnector = (ServerConnector) server.getConnectors()[0];
HttpConnectionFactory httpFactory =
existingConnector.getConnectionFactory(HttpConnectionFactory.class);
if (httpFactory != null) {
HttpConfiguration httpConfig = httpFactory.getHttpConfiguration();
httpConfig.setSecurePort(Config.https_port);
httpConfig.setSecureScheme("https");
}
);
}
});
}
}
}
Loading