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
8952cff2
Commit
8952cff2
authored
Apr 26, 2016
by
Nicolas Byl
Committed by
Dave Syer
Apr 26, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the original query string when forwarding the request
to ensure compatibility with legacy apps Fixes gh-989
parent
1c3de94c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
12 deletions
+30
-12
ProxyRequestHelper.java
...mework/cloud/netflix/zuul/filters/ProxyRequestHelper.java
+12
-2
SimpleHostRoutingFilter.java
...d/netflix/zuul/filters/route/SimpleHostRoutingFilter.java
+7
-10
ProxyRequestHelperTests.java
...k/cloud/netflix/zuul/filters/ProxyRequestHelperTests.java
+11
-0
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/ProxyRequestHelper.java
View file @
8952cff2
...
...
@@ -230,14 +230,20 @@ public class ProxyRequestHelper {
}
public
Map
<
String
,
Object
>
debug
(
String
verb
,
String
uri
,
MultiValueMap
<
String
,
String
>
headers
,
MultiValueMap
<
String
,
String
>
params
,
MultiValueMap
<
String
,
String
>
headers
,
MultiValueMap
<
String
,
String
>
params
,
InputStream
requestEntity
)
throws
IOException
{
return
debug
(
verb
,
uri
,
headers
,
getQueryString
(
params
),
requestEntity
);
}
public
Map
<
String
,
Object
>
debug
(
String
verb
,
String
uri
,
MultiValueMap
<
String
,
String
>
headers
,
String
queryString
,
InputStream
requestEntity
)
throws
IOException
{
Map
<
String
,
Object
>
info
=
new
LinkedHashMap
<>();
if
(
this
.
traces
!=
null
)
{
RequestContext
context
=
RequestContext
.
getCurrentContext
();
info
.
put
(
"method"
,
verb
);
info
.
put
(
"path"
,
uri
);
info
.
put
(
"query"
,
getQueryString
(
params
)
);
info
.
put
(
"query"
,
queryString
);
info
.
put
(
"remote"
,
true
);
info
.
put
(
"proxy"
,
context
.
get
(
"proxy"
));
Map
<
String
,
Object
>
trace
=
new
LinkedHashMap
<>();
...
...
@@ -334,4 +340,8 @@ public class ProxyRequestHelper {
UriTemplate
template
=
new
UriTemplate
(
"?"
+
query
.
toString
().
substring
(
1
));
return
template
.
expand
(
singles
).
toString
();
}
public
String
formatQueryString
(
String
queryString
)
{
return
(
queryString
==
null
)
?
""
:
"?"
+
queryString
;
}
}
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/SimpleHostRoutingFilter.java
View file @
8952cff2
...
...
@@ -158,8 +158,6 @@ public class SimpleHostRoutingFilter extends ZuulFilter {
HttpServletRequest
request
=
context
.
getRequest
();
MultiValueMap
<
String
,
String
>
headers
=
this
.
helper
.
buildZuulRequestHeaders
(
request
);
MultiValueMap
<
String
,
String
>
params
=
this
.
helper
.
buildZuulRequestQueryParams
(
request
);
String
verb
=
getVerb
(
request
);
InputStream
requestEntity
=
getRequestBody
(
request
);
if
(
request
.
getContentLength
()
<
0
)
{
...
...
@@ -171,7 +169,7 @@ public class SimpleHostRoutingFilter extends ZuulFilter {
try
{
HttpResponse
response
=
forward
(
this
.
httpClient
,
verb
,
uri
,
request
,
headers
,
params
,
requestEntity
);
request
.
getQueryString
()
,
requestEntity
);
setResponse
(
response
);
}
catch
(
Exception
ex
)
{
...
...
@@ -248,9 +246,9 @@ public class SimpleHostRoutingFilter extends ZuulFilter {
private
HttpResponse
forward
(
HttpClient
httpclient
,
String
verb
,
String
uri
,
HttpServletRequest
request
,
MultiValueMap
<
String
,
String
>
headers
,
MultiValueMap
<
String
,
String
>
params
,
InputStream
requestEntity
)
String
queryString
,
InputStream
requestEntity
)
throws
Exception
{
Map
<
String
,
Object
>
info
=
this
.
helper
.
debug
(
verb
,
uri
,
headers
,
params
,
Map
<
String
,
Object
>
info
=
this
.
helper
.
debug
(
verb
,
uri
,
headers
,
queryString
,
requestEntity
);
URL
host
=
RequestContext
.
getCurrentContext
().
getRouteHost
();
HttpHost
httpHost
=
getHttpHost
(
host
);
...
...
@@ -261,24 +259,23 @@ public class SimpleHostRoutingFilter extends ZuulFilter {
ContentType
.
create
(
request
.
getContentType
()));
switch
(
verb
.
toUpperCase
())
{
case
"POST"
:
HttpPost
httpPost
=
new
HttpPost
(
uri
+
this
.
helper
.
getQueryString
(
params
));
HttpPost
httpPost
=
new
HttpPost
(
uri
+
this
.
helper
.
formatQueryString
(
queryString
));
httpRequest
=
httpPost
;
httpPost
.
setEntity
(
entity
);
break
;
case
"PUT"
:
HttpPut
httpPut
=
new
HttpPut
(
uri
+
this
.
helper
.
getQueryString
(
params
));
HttpPut
httpPut
=
new
HttpPut
(
uri
+
this
.
helper
.
formatQueryString
(
queryString
));
httpRequest
=
httpPut
;
httpPut
.
setEntity
(
entity
);
break
;
case
"PATCH"
:
HttpPatch
httpPatch
=
new
HttpPatch
(
uri
+
this
.
helper
.
getQueryString
(
params
));
HttpPatch
httpPatch
=
new
HttpPatch
(
uri
+
this
.
helper
.
formatQueryString
(
queryString
));
httpRequest
=
httpPatch
;
httpPatch
.
setEntity
(
entity
);
break
;
default
:
httpRequest
=
new
BasicHttpRequest
(
verb
,
uri
+
this
.
helper
.
getQueryString
(
params
));
log
.
debug
(
uri
+
this
.
helper
.
getQueryString
(
params
));
uri
+
this
.
helper
.
formatQueryString
(
queryString
));
}
try
{
httpRequest
.
setHeaders
(
convertHeaders
(
headers
));
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/ProxyRequestHelperTests.java
View file @
8952cff2
...
...
@@ -259,4 +259,15 @@ public class ProxyRequestHelperTests {
assertThat
(
queryString
,
is
(
"?wsdl"
));
}
@Test
public
void
formatQueryStringShouldPrependQuestionMark
()
{
String
queryString
=
new
ProxyRequestHelper
().
formatQueryString
(
"a=1234&b=5678"
);
assertThat
(
queryString
,
is
(
"?a=1234&b=5678"
));
}
@Test
public
void
formatQueryStringShouldReturnEmptyStringForNullValue
()
{
assertThat
(
new
ProxyRequestHelper
().
formatQueryString
(
null
),
is
(
""
));
}
}
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