Comments (4)
Disable the cookie manager of the httpclient
I think this is the only option.
from spring-cloud-gateway.
Yes it's our method for the moment, but the code are really ugly :
/** GatewayServerMvcAutoConfiguration.gatewayClientHttpRequestFactory */
@Bean
public ClientHttpRequestFactory gatewayClientHttpRequestFactory(GatewayMvcProperties gatewayMvcProperties,
SslBundles sslBundles) {
GatewayMvcProperties.HttpClient properties = gatewayMvcProperties.getHttpClient();
SslBundle sslBundle = null;
if (org.springframework.util.StringUtils.hasText(properties.getSslBundle())) {
sslBundle = sslBundles.getBundle(properties.getSslBundle());
}
ClientHttpRequestFactorySettings settings = new ClientHttpRequestFactorySettings(properties.getConnectTimeout(),
properties.getReadTimeout(), sslBundle);
ClientHttpRequestFactory chrf;
if (properties.getType() == GatewayMvcProperties.HttpClientType.JDK) {
// TODO: customize restricted headers
String restrictedHeaders = System.getProperty("jdk.httpclient.allowRestrictedHeaders");
if (!org.springframework.util.StringUtils.hasText(restrictedHeaders)) {
System.setProperty("jdk.httpclient.allowRestrictedHeaders", "host");
}
else if (org.springframework.util.StringUtils.hasText(restrictedHeaders) && !restrictedHeaders.contains("host")) {
System.setProperty("jdk.httpclient.allowRestrictedHeaders", restrictedHeaders + ",host");
}
chrf = ClientHttpRequestFactories.get(JdkClientHttpRequestFactory.class, settings);
} else {
chrf = ClientHttpRequestFactories.get(settings);
}
log.error("chrf : {}", chrf);
if (chrf instanceof HttpComponentsClientHttpRequestFactory hcchrf) {
log.error("hcchrf.getHttpClient() : {}", hcchrf.getHttpClient());
} else if (chrf instanceof JdkClientHttpRequestFactory jchrf) {
try {
Field field = jchrf.getClass().getDeclaredField("httpClient");
field.setAccessible(true);
Object httpClient = field.get(jchrf);
log.error("jchrf.getHttpClient() : {}", httpClient);
} catch (Exception e) {
log.error("", e);
}
}
if (chrf instanceof HttpComponentsClientHttpRequestFactory hcchrf) {
hcchrf.setHttpClient(createHttpClient(settings.readTimeout(), settings.sslBundle()));
}
return chrf;
}
private static HttpClient createHttpClient(Duration readTimeout, SslBundle sslBundle) {
PoolingHttpClientConnectionManagerBuilder connectionManagerBuilder = PoolingHttpClientConnectionManagerBuilder
.create();
if (readTimeout != null) {
SocketConfig socketConfig = SocketConfig.custom()
.setSoTimeout((int) readTimeout.toMillis(), TimeUnit.MILLISECONDS)
.build();
connectionManagerBuilder.setDefaultSocketConfig(socketConfig);
}
if (sslBundle != null) {
SslOptions options = sslBundle.getOptions();
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslBundle.createSslContext(),
options.getEnabledProtocols(), options.getCiphers(), new DefaultHostnameVerifier());
connectionManagerBuilder.setSSLSocketFactory(socketFactory);
}
PoolingHttpClientConnectionManager connectionManager = connectionManagerBuilder.useSystemProperties()
.build();
// We disabled the cookie management here
return HttpClientBuilder.create().useSystemProperties().disableCookieManagement().setConnectionManager(connectionManager).build();
}
from spring-cloud-gateway.
#3305 will simplify that.
from spring-cloud-gateway.
It's seen more for spring cloud gateway mvc to disable it by default, not the user
from spring-cloud-gateway.
Related Issues (20)
- [spring-cloud-gateway-mvc] forward operation has side affects HOT 2
- Add support for multiple proto files in one descriptor for JsonToGrpcGatewayFilterFactory HOT 3
- Gateway issue with image upload. HOT 4
- Spring Cloud Gateway Server MVC rateLimit filter(Bucket4jFilter) will got UnsupportedOperationException when response headers is ReadOnlyHttpHeaders HOT 2
- Gateway MVC forward request but with decoded parameters (%2B becomes +)
- "spring.cloud.gateway.requests" metric not incremented for subsequent cached responses
- Question migrate Apache httpd to spring gateway HOT 6
- 500 when CORS and CircuitBreaker are aplied to the same route HOT 9
- Global exception handling with Spring Cloud Gateway MVC HOT 1
- the gateway can modify the queryparams of the URL by Get request? HOT 4
- X-Forwarded-Prefix not working when using MVC
- org.springframework.core.io.buffer.DefaultDataBuffer cannot be cast to org.springframework.core.io.buffer.NettyDataBuffer HOT 5
- Spring Native doesn't work with Spring Gateway: java.lang.IllegalStateException: Incompatible Tomcat implementation HOT 2
- spring-cloud-gateway cpu100%
- [Question] Routing of the requests with multipart file upload limitations
- Migrate mvc proxy exchange properties to new namespace and deprecate old
- Migrate webflux proxy exchange properties to new namespace and deprecate old
- Migrate server-webflux properties to new namespace and deprecate old
- Migrate server-webmvc properties to new namespace and deprecate old
- Serve Single Page Applications as static files in Spring Cloud Gateway HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-cloud-gateway.