camel jetty header 과 다 한 문제 해결 방법
5993 단어 Camel
package com.xiaoka.camel.springboot.example.component;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.component.jetty.CamelHttpClient;
import org.apache.camel.component.jetty.JettyHttpComponent;
import org.apache.camel.component.jetty.JettyHttpEndpoint;
import org.apache.camel.component.jetty9.CamelHttpClient9;
import org.apache.camel.component.jetty9.JettyHttpEndpoint9;
import org.apache.camel.support.IntrospectionSupport;
import org.eclipse.jetty.client.HttpClientTransport;
import org.eclipse.jetty.server.*;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
* @author liuchengbiao
* @date 2019-06-03 14:56
*/
public class JettyComponentDemo extends JettyHttpComponent {
private static final Logger LOG = LoggerFactory.getLogger(JettyComponentDemo.class);
protected CamelHttpClient createCamelHttpClient(HttpClientTransport transport, SslContextFactory sslContextFactory) {
return new CamelHttpClient9(transport, sslContextFactory);
}
protected JettyHttpEndpoint createEndpoint(URI endpointUri, URI httpUri) throws URISyntaxException {
return new JettyHttpEndpoint9(this, endpointUri.toString(), httpUri);
}
protected AbstractConnector createConnectorJettyInternal(Server server,
JettyHttpEndpoint endpoint,
SslContextFactory sslcf) {
try {
String host = endpoint.getHttpUri().getHost();
int port = endpoint.getPort();
org.eclipse.jetty.server.HttpConfiguration httpConfig = new org.eclipse.jetty.server.HttpConfiguration();
httpConfig.setSendServerVersion(endpoint.isSendServerVersion());
httpConfig.setSendDateHeader(endpoint.isSendDateHeader());
System.out.println(" ");
if (requestBufferSize != null) {
// Does not work
//httpConfig.setRequestBufferSize(requestBufferSize);
}
if (requestHeaderSize != null) {
httpConfig.setRequestHeaderSize(requestHeaderSize);
}
if (responseBufferSize != null) {
httpConfig.setOutputBufferSize(responseBufferSize);
}
int size = 1024 * 1024 * 10;
httpConfig.setRequestHeaderSize(size);
httpConfig.setResponseHeaderSize(size);
if (responseHeaderSize != null) {
httpConfig.setResponseHeaderSize(responseHeaderSize);
}
if (useXForwardedForHeader) {
httpConfig.addCustomizer(new ForwardedRequestCustomizer());
}
HttpConnectionFactory httpFactory = new org.eclipse.jetty.server.HttpConnectionFactory(httpConfig);
ArrayList connectionFactories = new ArrayList<>();
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);
for (ConnectionFactory cf : connectionFactories) {
result.addConnectionFactory(cf);
}
result.setPort(port);
if (host != null) {
result.setHost(host);
}
if (sslcf != null) {
if (getSslSocketConnectorProperties() != null && "https".equals(endpoint.getProtocol())) {
// must copy the map otherwise it will be deleted
Map properties = new HashMap<>(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 + "]");
}
}
LOG.info("Connector on port: {} is using includeCipherSuites: {} excludeCipherSuites: {} includeProtocols: {} excludeProtocols: {}",
port, sslcf.getIncludeCipherSuites(), sslcf.getExcludeCipherSuites(), sslcf.getIncludeProtocols(), sslcf.getExcludeProtocols());
}
return result;
} catch (Exception e) {
throw RuntimeCamelException.wrapRuntimeCamelException(e);
}
}
}
@Bean("jetty")
public JettyComponentDemo nothing() {
JettyComponentDemo jetty = new JettyComponentDemo();
int size = 1024 * 1024 * 10;
jetty.setRequestHeaderSize(size);
jetty.setResponseHeaderSize(size);
return jetty;
}
위 와 같은 수정 을 통 해 최대 header 값 을 10M 으로 전송 할 수 있 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
camel jetty header 과 다 한 문제 해결 방법camel 에서 Jetty 구성 요 소 를 사용 하면 http 인터페이스의 호출 과 감청 을 완성 할 수 있 습 니 다. 그러나 호출 할 때 header 매개 변수 값 이 너무 크 면 이상 정 보 를 던 집 니 다....
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.