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
4a1e637b
Commit
4a1e637b
authored
May 24, 2016
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix content type when missing from incoming request
If there is no content type incoming, then it should be absent in the outgoing request (not "null"). Fixes gh-1037
parent
d19a6f26
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
SimpleHostRoutingFilter.java
...d/netflix/zuul/filters/route/SimpleHostRoutingFilter.java
+2
-1
SampleZuulProxyApplicationTests.java
...k/cloud/netflix/zuul/SampleZuulProxyApplicationTests.java
+17
-0
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/SimpleHostRoutingFilter.java
View file @
4a1e637b
...
...
@@ -258,7 +258,8 @@ public class SimpleHostRoutingFilter extends ZuulFilter {
HttpRequest
httpRequest
;
int
contentLength
=
request
.
getContentLength
();
InputStreamEntity
entity
=
new
InputStreamEntity
(
requestEntity
,
contentLength
,
ContentType
.
create
(
request
.
getContentType
()));
request
.
getContentType
()
!=
null
?
ContentType
.
create
(
request
.
getContentType
())
:
null
);
switch
(
verb
.
toUpperCase
())
{
case
"POST"
:
HttpPost
httpPost
=
new
HttpPost
(
uri
+
this
.
helper
.
getQueryString
(
params
));
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/SampleZuulProxyApplicationTests.java
View file @
4a1e637b
...
...
@@ -158,6 +158,17 @@ public class SampleZuulProxyApplicationTests extends ZuulProxyTestBase {
}
@Test
public
void
simpleHostRouteWithContentType
()
{
this
.
routes
.
addRoute
(
"/self/**"
,
"http://localhost:"
+
this
.
port
+
"/"
);
this
.
endpoint
.
reset
();
ResponseEntity
<
String
>
result
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
this
.
port
+
"/self/content-type"
,
HttpMethod
.
POST
,
new
HttpEntity
<>((
Void
)
null
),
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
result
.
getStatusCode
());
assertEquals
(
"<NONE>"
,
result
.
getBody
());
}
@Test
public
void
ribbonCommandForbidden
()
{
ResponseEntity
<
String
>
result
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
this
.
port
+
"/simple/throwexception/403"
,
...
...
@@ -223,6 +234,12 @@ class SampleZuulProxyApplication extends ZuulProxyTestBase.AbstractZuulProxyAppl
return
request
.
getRequestURI
();
}
@RequestMapping
(
"/content-type"
)
public
String
contentType
(
HttpServletRequest
request
)
{
String
header
=
request
.
getHeader
(
"Content-Type"
);
return
header
==
null
?
"<NONE>"
:
header
;
}
@RequestMapping
(
"/add-header"
)
public
ResponseEntity
<
String
>
addHeader
(
HttpServletRequest
request
)
{
HttpHeaders
headers
=
new
HttpHeaders
();
...
...
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