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
b108de33
Commit
b108de33
authored
Dec 15, 2015
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #713 from kakawait/gh-583
* gh-583: Removing multiple successive slashes
parents
804abb6d
982288ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
SimpleHostRoutingFilter.java
...d/netflix/zuul/filters/route/SimpleHostRoutingFilter.java
+1
-1
SampleZuulProxyApplicationTests.java
...k/cloud/netflix/zuul/SampleZuulProxyApplicationTests.java
+20
-3
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/SimpleHostRoutingFilter.java
View file @
b108de33
...
...
@@ -241,7 +241,7 @@ public class SimpleHostRoutingFilter extends ZuulFilter {
requestEntity
);
URL
host
=
RequestContext
.
getCurrentContext
().
getRouteHost
();
HttpHost
httpHost
=
getHttpHost
(
host
);
uri
=
StringUtils
.
cleanPath
(
host
.
getPath
()
+
uri
);
uri
=
StringUtils
.
cleanPath
(
(
host
.
getPath
()
+
uri
).
replaceAll
(
"/{2,}"
,
"/"
)
);
HttpRequest
httpRequest
;
switch
(
verb
.
toUpperCase
())
{
case
"POST"
:
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/SampleZuulProxyApplicationTests.java
View file @
b108de33
...
...
@@ -16,13 +16,11 @@
package
org
.
springframework
.
cloud
.
netflix
.
zuul
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -64,6 +62,9 @@ import com.netflix.loadbalancer.ServerList;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.context.RequestContext
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleZuulProxyApplication
.
class
)
@WebAppConfiguration
...
...
@@ -189,6 +190,17 @@ public class SampleZuulProxyApplicationTests {
}
@Test
public
void
simpleHostRouteWithTrailingSlash
()
{
routes
.
addRoute
(
"/self/**"
,
"http://localhost:"
+
this
.
port
+
"/"
);
this
.
endpoint
.
reset
();
ResponseEntity
<
String
>
result
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
this
.
port
+
"/self/trailing-slash"
,
HttpMethod
.
GET
,
new
HttpEntity
<>((
Void
)
null
),
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
result
.
getStatusCode
());
assertEquals
(
"/trailing-slash"
,
result
.
getBody
());
}
@Test
public
void
ribbonCommandFactoryOverridden
()
{
assertTrue
(
"ribbonCommandFactory not a MyRibbonCommandFactory"
,
ribbonCommandFactory
instanceof
SampleZuulProxyApplication
.
MyRibbonCommandFactory
);
...
...
@@ -246,6 +258,11 @@ class SampleZuulProxyApplication {
return
"Hello space"
;
}
@RequestMapping
(
value
=
"/trailing-slash"
)
public
String
trailingSlash
(
HttpServletRequest
request
)
{
return
request
.
getRequestURI
();
}
@Bean
public
RibbonCommandFactory
ribbonCommandFactory
(
SpringClientFactory
clientFactory
)
{
return
new
MyRibbonCommandFactory
(
clientFactory
);
...
...
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