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
50b53c42
Commit
50b53c42
authored
Jun 07, 2018
by
Ryan Baxter
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/1.4.x'
parents
bb446cb5
84084fc3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
ProxyRequestHelper.java
...mework/cloud/netflix/zuul/filters/ProxyRequestHelper.java
+2
-0
ProxyRequestHelperTests.java
...k/cloud/netflix/zuul/filters/ProxyRequestHelperTests.java
+24
-0
No files found.
spring-cloud-netflix-zuul/src/main/java/org/springframework/cloud/netflix/zuul/filters/ProxyRequestHelper.java
View file @
50b53c42
...
@@ -161,6 +161,8 @@ public class ProxyRequestHelper {
...
@@ -161,6 +161,8 @@ public class ProxyRequestHelper {
for
(
Entry
<
String
,
List
<
String
>>
header
:
headers
.
entrySet
())
{
for
(
Entry
<
String
,
List
<
String
>>
header
:
headers
.
entrySet
())
{
String
name
=
header
.
getKey
();
String
name
=
header
.
getKey
();
for
(
String
value
:
header
.
getValue
())
{
for
(
String
value
:
header
.
getValue
())
{
context
.
addOriginResponseHeader
(
name
,
value
);
if
(
name
.
equalsIgnoreCase
(
HttpHeaders
.
CONTENT_ENCODING
)
if
(
name
.
equalsIgnoreCase
(
HttpHeaders
.
CONTENT_ENCODING
)
&&
HTTPRequestUtils
.
getInstance
().
isGzipped
(
value
))
{
&&
HTTPRequestUtils
.
getInstance
().
isGzipped
(
value
))
{
isOriginResponseGzipped
=
true
;
isOriginResponseGzipped
=
true
;
...
...
spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/filters/ProxyRequestHelperTests.java
View file @
50b53c42
...
@@ -19,6 +19,7 @@ package org.springframework.cloud.netflix.zuul.filters;
...
@@ -19,6 +19,7 @@ package org.springframework.cloud.netflix.zuul.filters;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
import
com.netflix.util.Pair
;
import
com.netflix.zuul.context.RequestContext
;
import
com.netflix.zuul.context.RequestContext
;
import
org.assertj.core.api.Assertions
;
import
org.assertj.core.api.Assertions
;
import
org.junit.After
;
import
org.junit.After
;
...
@@ -37,6 +38,7 @@ import org.springframework.util.LinkedMultiValueMap;
...
@@ -37,6 +38,7 @@ import org.springframework.util.LinkedMultiValueMap;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
static
org
.
hamcrest
.
Matchers
.
contains
;
import
static
org
.
hamcrest
.
Matchers
.
contains
;
import
static
org
.
hamcrest
.
Matchers
.
containsInAnyOrder
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
hasSize
;
import
static
org
.
hamcrest
.
Matchers
.
hasSize
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
...
@@ -227,6 +229,28 @@ public class ProxyRequestHelperTests {
...
@@ -227,6 +229,28 @@ public class ProxyRequestHelperTests {
}
}
@Test
@Test
public
void
setResponseShouldSetOriginResponseHeaders
()
throws
IOException
{
MockHttpServletRequest
request
=
new
MockHttpServletRequest
(
"POST"
,
"/"
);
MockHttpServletResponse
response
=
new
MockHttpServletResponse
();
RequestContext
context
=
RequestContext
.
getCurrentContext
();
context
.
setRequest
(
request
);
context
.
setResponse
(
response
);
ProxyRequestHelper
helper
=
new
ProxyRequestHelper
();
MultiValueMap
<
String
,
String
>
headers
=
new
HttpHeaders
();
headers
.
add
(
HttpHeaders
.
CONTENT_TYPE
,
"text/plain"
);
headers
.
add
(
"some-header"
,
"some-value"
);
helper
.
setResponse
(
200
,
request
.
getInputStream
(),
headers
);
assertThat
(
context
.
getOriginResponseHeaders
(),
containsInAnyOrder
(
new
Pair
<>(
HttpHeaders
.
CONTENT_TYPE
,
"text/plain"
),
new
Pair
<>(
"some-header"
,
"some-value"
)
));
}
@Test
public
void
setResponseUppercase
()
throws
IOException
{
public
void
setResponseUppercase
()
throws
IOException
{
MockHttpServletRequest
request
=
new
MockHttpServletRequest
(
"POST"
,
"/"
);
MockHttpServletRequest
request
=
new
MockHttpServletRequest
(
"POST"
,
"/"
);
MockHttpServletResponse
response
=
new
MockHttpServletResponse
();
MockHttpServletResponse
response
=
new
MockHttpServletResponse
();
...
...
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