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
12bee777
Commit
12bee777
authored
Jun 23, 2015
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #408 from brandon-atkinson/zuul-unescaped-paths
* zuul-unescaped-paths: Fix unescaped paths in SimpleHostRoutingFilter.
parents
0b925e5a
283c0f76
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
10 deletions
+34
-10
ProxyRequestHelper.java
...mework/cloud/netflix/zuul/filters/ProxyRequestHelper.java
+18
-0
RibbonCommand.java
...ework/cloud/netflix/zuul/filters/route/RibbonCommand.java
+1
-1
RibbonRoutingFilter.java
...cloud/netflix/zuul/filters/route/RibbonRoutingFilter.java
+2
-4
SimpleHostRoutingFilter.java
...d/netflix/zuul/filters/route/SimpleHostRoutingFilter.java
+1
-4
SampleZuulProxyApplicationTests.java
...k/cloud/netflix/zuul/SampleZuulProxyApplicationTests.java
+12
-1
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/ProxyRequestHelper.java
View file @
12bee777
...
...
@@ -29,6 +29,7 @@ import java.util.Set;
import
javax.servlet.http.HttpServletRequest
;
import
lombok.extern.apachecommons.CommonsLog
;
import
org.apache.commons.io.IOUtils
;
import
org.springframework.boot.actuate.trace.TraceRepository
;
import
org.springframework.util.LinkedMultiValueMap
;
...
...
@@ -37,10 +38,13 @@ import org.springframework.util.StringUtils;
import
com.netflix.zuul.context.RequestContext
;
import
com.netflix.zuul.util.HTTPRequestUtils
;
import
org.springframework.web.util.UriUtils
;
import
org.springframework.web.util.WebUtils
;
/**
* @author Dave Syer
*/
@CommonsLog
public
class
ProxyRequestHelper
{
/**
...
...
@@ -57,6 +61,20 @@ public class ProxyRequestHelper {
this
.
traces
=
traces
;
}
public
String
buildZuulRequestURI
(
HttpServletRequest
request
)
{
RequestContext
context
=
RequestContext
.
getCurrentContext
();
String
uri
=
request
.
getRequestURI
();
String
contextURI
=
(
String
)
context
.
get
(
"requestURI"
);
if
(
contextURI
!=
null
)
{
try
{
uri
=
UriUtils
.
encodePath
(
contextURI
,
WebUtils
.
DEFAULT_CHARACTER_ENCODING
);
}
catch
(
Exception
e
)
{
log
.
debug
(
"unable to encode uri path from context, falling back to uri from request"
,
e
);
}
}
return
uri
;
}
public
MultiValueMap
<
String
,
String
>
buildZuulRequestQueryParams
(
HttpServletRequest
request
)
{
Map
<
String
,
List
<
String
>>
map
=
HTTPRequestUtils
.
getInstance
().
getQueryParams
();
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/RibbonCommand.java
View file @
12bee777
...
...
@@ -80,7 +80,7 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> {
super
(
getSetter
(
commandKey
));
this
.
restClient
=
restClient
;
this
.
verb
=
verb
;
this
.
uri
=
(
StringUtils
.
hasText
(
uri
))?
UriComponentsBuilder
.
fromUriString
(
uri
).
build
().
toUri
()
:
new
URI
(
uri
);
this
.
uri
=
new
URI
(
uri
);
this
.
retryable
=
retryable
;
this
.
headers
=
headers
;
this
.
params
=
params
;
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/RibbonRoutingFilter.java
View file @
12bee777
...
...
@@ -95,10 +95,8 @@ public class RibbonRoutingFilter extends ZuulFilter {
RestClient
restClient
=
this
.
clientFactory
.
getClient
(
serviceId
,
RestClient
.
class
);
String
uri
=
request
.
getRequestURI
();
if
(
context
.
get
(
"requestURI"
)
!=
null
)
{
uri
=
(
String
)
context
.
get
(
"requestURI"
);
}
String
uri
=
this
.
helper
.
buildZuulRequestURI
(
request
);
// remove double slashes
uri
=
uri
.
replace
(
"//"
,
"/"
);
String
service
=
(
String
)
context
.
get
(
"serviceId"
);
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/SimpleHostRoutingFilter.java
View file @
12bee777
...
...
@@ -168,10 +168,7 @@ public class SimpleHostRoutingFilter extends ZuulFilter {
InputStream
requestEntity
=
getRequestBody
(
request
);
HttpClient
httpclient
=
CLIENT
.
get
();
String
uri
=
request
.
getRequestURI
();
if
(
context
.
get
(
"requestURI"
)
!=
null
)
{
uri
=
(
String
)
context
.
get
(
"requestURI"
);
}
String
uri
=
this
.
helper
.
buildZuulRequestURI
(
request
);
try
{
HttpResponse
response
=
forward
(
httpclient
,
verb
,
uri
,
request
,
headers
,
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/SampleZuulProxyApplicationTests.java
View file @
12bee777
...
...
@@ -134,7 +134,7 @@ public class SampleZuulProxyApplicationTests {
}
@Test
public
void
routeWithSpace
()
{
public
void
r
ibbonR
outeWithSpace
()
{
ResponseEntity
<
String
>
result
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
this
.
port
+
"/simple/spa ce"
,
HttpMethod
.
GET
,
new
HttpEntity
<>((
Void
)
null
),
String
.
class
);
...
...
@@ -142,6 +142,17 @@ public class SampleZuulProxyApplicationTests {
assertEquals
(
"Hello space"
,
result
.
getBody
());
}
@Test
public
void
simpleHostRouteWithSpace
()
{
routes
.
addRoute
(
"/self/**"
,
"http://localhost:"
+
this
.
port
);
this
.
endpoint
.
reset
();
ResponseEntity
<
String
>
result
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
this
.
port
+
"/self/spa ce"
,
HttpMethod
.
GET
,
new
HttpEntity
<>((
Void
)
null
),
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
result
.
getStatusCode
());
assertEquals
(
"Hello space"
,
result
.
getBody
());
}
}
// Don't use @SpringBootApplication because we don't want to component scan
...
...
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