Skip to content

Commit

Permalink
[feature]add standard cookie specifications config in connection config
Browse files Browse the repository at this point in the history
default value for cookieSpecPolicy is ignore
  • Loading branch information
A.Alimohammadi authored and A.Alimohammadi committed Nov 14, 2023
1 parent 532ebcc commit 226aadd
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 31 deletions.
63 changes: 32 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,37 +226,38 @@ You can define client config class custom prefix for setting that inherit HttpCl
All configuration values are prefixed by your defined prefix. (e.g. prefix=custom-service.client `custom-service.client.connection.connectionTimeout`).


| Config | Description | Default | Example |
|----------------------------------------------|--------------------------------------|---|---|
| baseServiceUrl | Base service url (required) | | `localhost:8080/example` |
| sslContext | SSL Version (optional) | `TLSv1.2` | `TLSv1.1` |
| connection.connectionTimeout (optional) | Connection Timeout in ms | 5000 | `2000` |
| connection.socketTimeout (optional) | Socket Timeout in ms | 10000 | `5000` |
| connection.maxConnections (optional) | max number of connections | 200 | `100` |
| connection.maxConnectionsPerRoute (optional) | max number of connections per route | 50 | `10` |
| connection.timeToLive (optional) | time to live | 900 | `300` |
| connection.timeToLiveUnit (optional) | time to live unit | SECONDS | `MINUTES` |
| connection.followRedirects (optional) | following redirects | true | `true` or `false` |
| connection.connectionTimerRepeat (optional) | connection timer repeat | 3000 | `1000` |
| proxy (optional) | Configuration for used proxy servers | | |
| proxy.enable | Proxy enable (optional) | false | `true` or `false` |
| proxy.host | Hostname or IP of the Proxy | | `192.168.7.130` or `corp-proxy.domain` |
| proxy.port | Port of the Proxy (optional) | | `100` |
| proxy.user | Proxy user name (optional) | | `testUser`|
| proxy.password | Proxy password (optional) | | `testPassword` |
| ssl (optional) | Configuration for ssl | | |
| ssl.enable | SSL Enable (optional) | false | `true` or `false` |
| ssl.context | SSL Version (optional) | `TLSv1.2` | `TLSv1.1` |
| ssl.check-validity | Check SSL validity (optional) | false | `true` or `false` |
| ssl.keystore.path | Keystore file path | | `classpath:keystore.jks` |
| ssl.keystore.password | Keystore password | | `changeit` |
| ssl.keystore.type | Keystore type (optional) | `JKS` | `PKCS12` |
| ssl.truststore.path | Truststore file path | | `classpath:truststore.jks` |
| ssl.truststore.password | Truststore password | | `changeit` |
| ssl.truststore.type | Truststore type (optional) | `JKS` | `PKCS12` |
| authorization.enable | Authorization enable (optional) | false | `true` or `false` |
| authorization.username | Authorization user name (optional) | | `testUser`|
| authorization.password | Authorization password (optional) | | `testPassword` |
| Config | Description | Default | Example |
|----------------------------------------------|--------------------------------------|-----------|----------------------------------------|
| baseServiceUrl | Base service url (required) | | `localhost:8080/example` |
| sslContext | SSL Version (optional) | `TLSv1.2` | `TLSv1.1` |
| connection.connectionTimeout (optional) | Connection Timeout in ms | 5000 | `2000` |
| connection.socketTimeout (optional) | Socket Timeout in ms | 10000 | `5000` |
| connection.maxConnections (optional) | max number of connections | 200 | `100` |
| connection.maxConnectionsPerRoute (optional) | max number of connections per route | 50 | `10` |
| connection.timeToLive (optional) | time to live | 900 | `300` |
| connection.timeToLiveUnit (optional) | time to live unit | SECONDS | `MINUTES` |
| connection.followRedirects (optional) | following redirects | true | `true` or `false` |
| connection.connectionTimerRepeat (optional) | connection timer repeat | 3000 | `1000` |
| connection.cookieSpecPolicy (optional) | Standard cookie specifications | `ignore` | `relaxed`,`strict`,`ignore` |
| proxy (optional) | Configuration for used proxy servers | | |
| proxy.enable | Proxy enable (optional) | false | `true` or `false` |
| proxy.host | Hostname or IP of the Proxy | | `192.168.7.130` or `corp-proxy.domain` |
| proxy.port | Port of the Proxy (optional) | | `100` |
| proxy.user | Proxy user name (optional) | | `testUser` |
| proxy.password | Proxy password (optional) | | `testPassword` |
| ssl (optional) | Configuration for ssl | | |
| ssl.enable | SSL Enable (optional) | false | `true` or `false` |
| ssl.context | SSL Version (optional) | `TLSv1.2` | `TLSv1.1` |
| ssl.check-validity | Check SSL validity (optional) | false | `true` or `false` |
| ssl.keystore.path | Keystore file path | | `classpath:keystore.jks` |
| ssl.keystore.password | Keystore password | | `changeit` |
| ssl.keystore.type | Keystore type (optional) | `JKS` | `PKCS12` |
| ssl.truststore.path | Truststore file path | | `classpath:truststore.jks` |
| ssl.truststore.password | Truststore password | | `changeit` |
| ssl.truststore.type | Truststore type (optional) | `JKS` | `PKCS12` |
| authorization.enable | Authorization enable (optional) | false | `true` or `false` |
| authorization.username | Authorization user name (optional) | | `testUser` |
| authorization.password | Authorization password (optional) | | `testPassword` |

Example:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tosan.client.http.core;

import org.apache.hc.client5.http.cookie.StandardCookieSpec;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.validation.annotation.Validated;

Expand Down Expand Up @@ -308,6 +309,8 @@ public static class ConnectionConfiguration {

private int socketTimeout = DEFAULT_SOCKET_TIMEOUT;

private String cookieSpecPolicy = StandardCookieSpec.IGNORE;


public int getMaxConnections() {
return maxConnections;
Expand Down Expand Up @@ -372,6 +375,14 @@ public int getSocketTimeout() {
public void setSocketTimeout(int socketTimeout) {
this.socketTimeout = socketTimeout;
}

public String getCookieSpecPolicy() {
return cookieSpecPolicy;
}

public void setCookieSpecPolicy(String cookieSpecPolicy) {
this.cookieSpecPolicy = cookieSpecPolicy;
}
}

public static class AuthorizationConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private void configureTimeouts(HttpClientBuilder builder) {
.setConnectTimeout(httpClientProperties.getConnection().getConnectionTimeout(), TimeUnit.MILLISECONDS)
.setConnectionRequestTimeout(httpClientProperties.getConnection().getSocketTimeout(), TimeUnit.MILLISECONDS)
.setRedirectsEnabled(httpClientProperties.getConnection().isFollowRedirects())
.setCookieSpec(httpClientProperties.getConnection().getCookieSpecPolicy())
.build());
}

Expand Down

0 comments on commit 226aadd

Please sign in to comment.