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
f3ced9e0
Commit
f3ced9e0
authored
Mar 16, 2015
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow zuul to have multiple values for each named header
fixes gh-260
parent
cc2159f7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
5 deletions
+76
-5
ProxyRequestHelper.java
...mework/cloud/netflix/zuul/filters/ProxyRequestHelper.java
+8
-5
ProxyRequestHelperTests.java
...k/cloud/netflix/zuul/filters/ProxyRequestHelperTests.java
+68
-0
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/ProxyRequestHelper.java
View file @
f3ced9e0
...
...
@@ -76,13 +76,16 @@ public class ProxyRequestHelper {
HttpServletRequest
request
)
{
RequestContext
context
=
RequestContext
.
getCurrentContext
();
MultiValueMap
<
String
,
String
>
headers
=
new
LinkedMultiValueMap
<>();
Enumeration
<
?
>
headerNames
=
request
.
getHeaderNames
();
Enumeration
<
String
>
headerNames
=
request
.
getHeaderNames
();
if
(
headerNames
!=
null
)
{
while
(
headerNames
.
hasMoreElements
())
{
String
name
=
(
String
)
headerNames
.
nextElement
();
String
value
=
request
.
getHeader
(
name
);
if
(
isIncludedHeader
(
name
))
{
headers
.
set
(
name
,
value
);
String
name
=
headerNames
.
nextElement
();
if
(
isIncludedHeader
(
name
))
{
Enumeration
<
String
>
values
=
request
.
getHeaders
(
name
);
while
(
values
.
hasMoreElements
())
{
String
value
=
values
.
nextElement
();
headers
.
add
(
name
,
value
);
}
}
}
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/ProxyRequestHelperTests.java
0 → 100644
View file @
f3ced9e0
/*
* Copyright 2013-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
cloud
.
netflix
.
zuul
.
filters
;
import
java.util.List
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.mockito.Mock
;
import
org.springframework.boot.actuate.trace.TraceRepository
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.util.MultiValueMap
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
hamcrest
.
Matchers
.*;
import
static
org
.
mockito
.
MockitoAnnotations
.
initMocks
;
/**
* @author Spencer Gibb
*/
public
class
ProxyRequestHelperTests
{
@Mock
private
TraceRepository
traceRepository
;
@Before
public
void
init
()
{
initMocks
(
this
);
}
@Test
public
void
buildZuulRequestHeadersWork
()
{
MockHttpServletRequest
request
=
new
MockHttpServletRequest
(
"GET"
,
"/"
);
request
.
addHeader
(
"singleName"
,
"singleValue"
);
request
.
addHeader
(
"multiName"
,
"multiValue1"
);
request
.
addHeader
(
"multiName"
,
"multiValue2"
);
ProxyRequestHelper
helper
=
new
ProxyRequestHelper
();
helper
.
setTraces
(
traceRepository
);
MultiValueMap
<
String
,
String
>
headers
=
helper
.
buildZuulRequestHeaders
(
request
);
List
<
String
>
singleName
=
headers
.
get
(
"singleName"
);
assertThat
(
singleName
,
is
(
notNullValue
()));
assertThat
(
singleName
.
size
(),
is
(
1
));
List
<
String
>
multiName
=
headers
.
get
(
"multiName"
);
assertThat
(
multiName
,
is
(
notNullValue
()));
assertThat
(
multiName
.
size
(),
is
(
2
));
List
<
String
>
missingName
=
headers
.
get
(
"missingName"
);
assertThat
(
missingName
,
is
(
nullValue
()));
}
}
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