Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
ba17eb6a
Unverified
Commit
ba17eb6a
authored
Feb 19, 2018
by
Ryan Baxter
Committed by
GitHub
Feb 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feign compression configuration fixes (#2717)
* feign compression configuration fixes. Fixes #2462
parent
31c974c4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
9 deletions
+34
-9
FeignAcceptGzipEncodingAutoConfiguration.java
...gn/encoding/FeignAcceptGzipEncodingAutoConfiguration.java
+7
-2
FeignContentGzipEncodingAutoConfiguration.java
...n/encoding/FeignContentGzipEncodingAutoConfiguration.java
+7
-2
HttpClientFeignLoadBalancedConfiguration.java
...eign/ribbon/HttpClientFeignLoadBalancedConfiguration.java
+20
-5
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/encoding/FeignAcceptGzipEncodingAutoConfiguration.java
View file @
ba17eb6a
...
...
@@ -16,12 +16,14 @@
package
org
.
springframework
.
cloud
.
netflix
.
feign
.
encoding
;
import
feign.Client
;
import
feign.Feign
;
import
feign.httpclient.Apache
HttpClient
;
import
okhttp3.Ok
HttpClient
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cloud.netflix.feign.FeignAutoConfiguration
;
...
...
@@ -37,8 +39,11 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties
(
FeignClientEncodingProperties
.
class
)
@ConditionalOnClass
(
Feign
.
class
)
@ConditionalOnBean
(
ApacheHttp
Client
.
class
)
@ConditionalOnBean
(
Client
.
class
)
@ConditionalOnProperty
(
value
=
"feign.compression.response.enabled"
,
matchIfMissing
=
false
)
//The OK HTTP client uses "transparent" compression.
//If the accept-encoding header is present it disable transparent compression
@ConditionalOnMissingBean
(
OkHttpClient
.
class
)
@AutoConfigureAfter
(
FeignAutoConfiguration
.
class
)
public
class
FeignAcceptGzipEncodingAutoConfiguration
{
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/encoding/FeignContentGzipEncodingAutoConfiguration.java
View file @
ba17eb6a
...
...
@@ -16,12 +16,14 @@
package
org
.
springframework
.
cloud
.
netflix
.
feign
.
encoding
;
import
feign.Client
;
import
feign.Feign
;
import
feign.httpclient.Apache
HttpClient
;
import
okhttp3.Ok
HttpClient
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cloud.netflix.feign.FeignAutoConfiguration
;
...
...
@@ -37,7 +39,10 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties
(
FeignClientEncodingProperties
.
class
)
@ConditionalOnClass
(
Feign
.
class
)
@ConditionalOnBean
(
ApacheHttpClient
.
class
)
@ConditionalOnBean
(
Client
.
class
)
//The OK HTTP client uses "transparent" compression.
//If the content-encoding header is present it disable transparent compression
@ConditionalOnMissingBean
(
OkHttpClient
.
class
)
@ConditionalOnProperty
(
value
=
"feign.compression.request.enabled"
,
matchIfMissing
=
false
)
@AutoConfigureAfter
(
FeignAutoConfiguration
.
class
)
public
class
FeignContentGzipEncodingAutoConfiguration
{
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/ribbon/HttpClientFeignLoadBalancedConfiguration.java
View file @
ba17eb6a
...
...
@@ -28,6 +28,7 @@ import org.apache.http.client.config.RequestConfig;
import
org.apache.http.config.RegistryBuilder
;
import
org.apache.http.conn.HttpClientConnectionManager
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClientBuilder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
...
...
@@ -78,17 +79,31 @@ class HttpClientFeignLoadBalancedConfiguration {
}
@Bean
public
CloseableHttpClient
httpClient
(
ApacheHttpClientFactory
httpClientFactory
,
HttpClientConnectionManager
httpClientConnectionManager
,
@ConditionalOnProperty
(
value
=
"feign.compression.response.enabled"
,
havingValue
=
"true"
)
public
CloseableHttpClient
customHttpClient
(
HttpClientConnectionManager
httpClientConnectionManager
,
FeignHttpClientProperties
httpClientProperties
)
{
HttpClientBuilder
builder
=
HttpClientBuilder
.
create
().
disableCookieManagement
().
useSystemProperties
();
this
.
httpClient
=
createClient
(
builder
,
httpClientConnectionManager
,
httpClientProperties
);
return
this
.
httpClient
;
}
@Bean
@ConditionalOnProperty
(
value
=
"feign.compression.response.enabled"
,
havingValue
=
"false"
,
matchIfMissing
=
true
)
public
CloseableHttpClient
httpClient
(
ApacheHttpClientFactory
httpClientFactory
,
HttpClientConnectionManager
httpClientConnectionManager
,
FeignHttpClientProperties
httpClientProperties
)
{
this
.
httpClient
=
createClient
(
httpClientFactory
.
createBuilder
(),
httpClientConnectionManager
,
httpClientProperties
);
return
this
.
httpClient
;
}
private
CloseableHttpClient
createClient
(
HttpClientBuilder
builder
,
HttpClientConnectionManager
httpClientConnectionManager
,
FeignHttpClientProperties
httpClientProperties
)
{
RequestConfig
defaultRequestConfig
=
RequestConfig
.
custom
()
.
setConnectTimeout
(
httpClientProperties
.
getConnectionTimeout
())
.
setRedirectsEnabled
(
httpClientProperties
.
isFollowRedirects
())
.
build
();
this
.
httpClient
=
httpClientFactory
.
createBuilder
().
setDefaultRequestConfig
(
defaultRequestConfig
).
CloseableHttpClient
httpClient
=
builder
.
setDefaultRequestConfig
(
defaultRequestConfig
).
setConnectionManager
(
httpClientConnectionManager
).
build
();
return
this
.
httpClient
;
return
httpClient
;
}
@PreDestroy
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment