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
658f29ed
Commit
658f29ed
authored
Nov 09, 2016
by
Ryan Baxter
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'Upstream/1.2.x' into feign-retry
parents
fad2c5d4
19556dc2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
14 deletions
+38
-14
SendResponseFilter.java
...k/cloud/netflix/zuul/filters/post/SendResponseFilter.java
+26
-7
FormBodyWrapperFilter.java
...cloud/netflix/zuul/filters/pre/FormBodyWrapperFilter.java
+0
-1
RibbonRoutingFilter.java
...cloud/netflix/zuul/filters/route/RibbonRoutingFilter.java
+12
-6
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/post/SendResponseFilter.java
View file @
658f29ed
...
...
@@ -16,17 +16,16 @@
package
org
.
springframework
.
cloud
.
netflix
.
zuul
.
filters
.
post
;
import
lombok.extern.apachecommons.CommonsLog
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.util.List
;
import
java.util.zip.GZIPInputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.util.ReflectionUtils
;
import
com.netflix.config.DynamicBooleanProperty
;
import
com.netflix.config.DynamicIntProperty
;
import
com.netflix.config.DynamicPropertyFactory
;
...
...
@@ -37,8 +36,6 @@ import com.netflix.zuul.constants.ZuulHeaders;
import
com.netflix.zuul.context.RequestContext
;
import
com.netflix.zuul.util.HTTPRequestUtils
;
import
lombok.extern.apachecommons.CommonsLog
;
/**
* @author Spencer Gibb
*/
...
...
@@ -56,6 +53,17 @@ public class SendResponseFilter extends ZuulFilter {
private
static
DynamicBooleanProperty
SET_CONTENT_LENGTH
=
DynamicPropertyFactory
.
getInstance
()
.
getBooleanProperty
(
ZuulConstants
.
ZUUL_SET_CONTENT_LENGTH
,
false
);
private
boolean
useServlet31
=
true
;
public
SendResponseFilter
()
{
super
();
// To support Servlet API 3.0.1 we need to check if setcontentLengthLong exists
try
{
HttpServletResponse
.
class
.
getMethod
(
"setContentLengthLong"
);
}
catch
(
NoSuchMethodException
e
)
{
useServlet31
=
false
;
}
}
@Override
public
String
filterType
()
{
...
...
@@ -210,10 +218,21 @@ public class SendResponseFilter extends ZuulFilter {
// Only inserts Content-Length if origin provides it and origin response is not
// gzipped
if
(
SET_CONTENT_LENGTH
.
get
())
{
if
(
contentLength
!=
null
&&
!
ctx
.
getResponseGZipped
())
{
servletResponse
.
setContentLengthLong
(
contentLength
);
if
(
contentLength
!=
null
&&
!
ctx
.
getResponseGZipped
())
{
if
(
useServlet31
)
{
servletResponse
.
setContentLengthLong
(
contentLength
);
}
else
{
//Try and set some kind of content length if we can safely convert the Long to an int
if
(
isLongSafe
(
contentLength
))
{
servletResponse
.
setContentLength
(
contentLength
.
intValue
());
}
}
}
}
}
private
boolean
isLongSafe
(
long
value
)
{
return
value
<=
Integer
.
MAX_VALUE
&&
value
>=
Integer
.
MIN_VALUE
;
}
}
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/pre/FormBodyWrapperFilter.java
View file @
658f29ed
...
...
@@ -170,7 +170,6 @@ public class FormBodyWrapperFilter extends ZuulFilter {
return
this
.
contentLength
;
}
@Override
public
long
getContentLengthLong
()
{
return
getContentLength
();
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/RibbonRoutingFilter.java
View file @
658f29ed
...
...
@@ -16,28 +16,25 @@
package
org
.
springframework
.
cloud
.
netflix
.
zuul
.
filters
.
route
;
import
lombok.extern.apachecommons.CommonsLog
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.cloud.netflix.ribbon.support.RibbonRequestCustomizer
;
import
org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.client.ClientHttpResponse
;
import
org.springframework.util.MultiValueMap
;
import
com.netflix.client.ClientException
;
import
com.netflix.hystrix.exception.HystrixRuntimeException
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.context.RequestContext
;
import
com.netflix.zuul.exception.ZuulException
;
import
lombok.extern.apachecommons.CommonsLog
;
@CommonsLog
public
class
RibbonRoutingFilter
extends
ZuulFilter
{
...
...
@@ -45,6 +42,7 @@ public class RibbonRoutingFilter extends ZuulFilter {
protected
ProxyRequestHelper
helper
;
protected
RibbonCommandFactory
<?>
ribbonCommandFactory
;
protected
List
<
RibbonRequestCustomizer
>
requestCustomizers
;
private
boolean
useServlet31
=
true
;
public
RibbonRoutingFilter
(
ProxyRequestHelper
helper
,
RibbonCommandFactory
<?>
ribbonCommandFactory
,
...
...
@@ -52,6 +50,12 @@ public class RibbonRoutingFilter extends ZuulFilter {
this
.
helper
=
helper
;
this
.
ribbonCommandFactory
=
ribbonCommandFactory
;
this
.
requestCustomizers
=
requestCustomizers
;
// To support Servlet API 3.0.1 we need to check if getcontentLengthLong exists
try
{
HttpServletResponse
.
class
.
getMethod
(
"getContentLengthLong"
);
}
catch
(
NoSuchMethodException
e
)
{
useServlet31
=
false
;
}
}
public
RibbonRoutingFilter
(
RibbonCommandFactory
<?>
ribbonCommandFactory
)
{
...
...
@@ -119,8 +123,10 @@ public class RibbonRoutingFilter extends ZuulFilter {
// remove double slashes
uri
=
uri
.
replace
(
"//"
,
"/"
);
long
contentLength
=
useServlet31
?
request
.
getContentLengthLong
():
request
.
getContentLength
();
return
new
RibbonCommandContext
(
serviceId
,
verb
,
uri
,
retryable
,
headers
,
params
,
requestEntity
,
this
.
requestCustomizers
,
request
.
getContentLengthLong
()
);
requestEntity
,
this
.
requestCustomizers
,
contentLength
);
}
protected
ClientHttpResponse
forward
(
RibbonCommandContext
context
)
throws
Exception
{
...
...
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