use of org.apache.camel.component.jetty.JettyHttpEndpoint in project camel by apache.
the class JettyHttpComponent9 method createConnectorJettyInternal.
protected AbstractConnector createConnectorJettyInternal(Server server, JettyHttpEndpoint endpoint, SslContextFactory sslcf) {
try {
String host = endpoint.getHttpUri().getHost();
int porto = endpoint.getPort();
org.eclipse.jetty.server.HttpConfiguration httpConfig = new org.eclipse.jetty.server.HttpConfiguration();
httpConfig.setSendServerVersion(endpoint.isSendServerVersion());
httpConfig.setSendDateHeader(endpoint.isSendDateHeader());
httpConfig.setSendDateHeader(endpoint.isSendDateHeader());
if (requestBufferSize != null) {
// Does not work
//httpConfig.setRequestBufferSize(requestBufferSize);
}
if (requestHeaderSize != null) {
httpConfig.setRequestHeaderSize(requestHeaderSize);
}
if (responseBufferSize != null) {
httpConfig.setOutputBufferSize(responseBufferSize);
}
if (responseHeaderSize != null) {
httpConfig.setResponseHeaderSize(responseHeaderSize);
}
if (useXForwardedForHeader) {
httpConfig.addCustomizer(new ForwardedRequestCustomizer());
}
HttpConnectionFactory httpFactory = new org.eclipse.jetty.server.HttpConnectionFactory(httpConfig);
ArrayList<ConnectionFactory> connectionFactories = new ArrayList<ConnectionFactory>();
ServerConnector result = new org.eclipse.jetty.server.ServerConnector(server);
if (sslcf != null) {
httpConfig.addCustomizer(new org.eclipse.jetty.server.SecureRequestCustomizer());
SslConnectionFactory scf = new org.eclipse.jetty.server.SslConnectionFactory(sslcf, "HTTP/1.1");
connectionFactories.add(scf);
// The protocol name can be "SSL" or "SSL-HTTP/1.1" depending on the version of Jetty
result.setDefaultProtocol(scf.getProtocol());
}
connectionFactories.add(httpFactory);
result.setConnectionFactories(connectionFactories);
result.setPort(porto);
if (host != null) {
result.setHost(host);
}
if (getSslSocketConnectorProperties() != null && "https".equals(endpoint.getProtocol())) {
// must copy the map otherwise it will be deleted
Map<String, Object> properties = new HashMap<String, Object>(getSslSocketConnectorProperties());
IntrospectionSupport.setProperties(sslcf, properties);
if (properties.size() > 0) {
throw new IllegalArgumentException("There are " + properties.size() + " parameters that couldn't be set on the SocketConnector." + " Check the uri if the parameters are spelt correctly and that they are properties of the SelectChannelConnector." + " Unknown parameters=[" + properties + "]");
}
}
return result;
} catch (Exception e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
}
Aggregations