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
5bd18e45
Commit
5bd18e45
authored
Mar 04, 2016
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mostly whitespace
parent
bda11adf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
17 deletions
+24
-17
SendResponseFilter.java
...k/cloud/netflix/zuul/filters/post/SendResponseFilter.java
+24
-17
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/post/SendResponseFilter.java
View file @
5bd18e45
...
...
@@ -22,6 +22,7 @@ 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
;
...
...
@@ -45,16 +46,16 @@ import lombok.extern.apachecommons.CommonsLog;
public
class
SendResponseFilter
extends
ZuulFilter
{
private
static
DynamicBooleanProperty
INCLUDE_DEBUG_HEADER
=
DynamicPropertyFactory
.
getInstance
()
.
getBooleanProperty
(
ZuulConstants
.
ZUUL_INCLUDE_DEBUG_HEADER
,
false
);
.
getInstance
()
.
getBooleanProperty
(
ZuulConstants
.
ZUUL_INCLUDE_DEBUG_HEADER
,
false
);
private
static
DynamicIntProperty
INITIAL_STREAM_BUFFER_SIZE
=
DynamicPropertyFactory
.
getInstance
()
.
getIntProperty
(
ZuulConstants
.
ZUUL_INITIAL_STREAM_BUFFER_SIZE
,
1024
);
.
getInstance
()
.
getIntProperty
(
ZuulConstants
.
ZUUL_INITIAL_STREAM_BUFFER_SIZE
,
1024
);
private
static
DynamicBooleanProperty
SET_CONTENT_LENGTH
=
DynamicPropertyFactory
.
getInstance
()
.
getBooleanProperty
(
ZuulConstants
.
ZUUL_SET_CONTENT_LENGTH
,
false
);
.
getInstance
()
.
getBooleanProperty
(
ZuulConstants
.
ZUUL_SET_CONTENT_LENGTH
,
false
);
@Override
public
String
filterType
()
{
...
...
@@ -88,7 +89,8 @@ public class SendResponseFilter extends ZuulFilter {
private
void
writeResponse
()
throws
Exception
{
RequestContext
context
=
RequestContext
.
getCurrentContext
();
// there is no body to send
if
(
context
.
getResponseBody
()
==
null
&&
context
.
getResponseDataStream
()
==
null
)
{
if
(
context
.
getResponseBody
()
==
null
&&
context
.
getResponseDataStream
()
==
null
)
{
return
;
}
HttpServletResponse
servletResponse
=
context
.
getResponse
();
...
...
@@ -100,12 +102,15 @@ public class SendResponseFilter extends ZuulFilter {
try
{
if
(
RequestContext
.
getCurrentContext
().
getResponseBody
()
!=
null
)
{
String
body
=
RequestContext
.
getCurrentContext
().
getResponseBody
();
writeResponse
(
new
ByteArrayInputStream
(
body
.
getBytes
(
servletResponse
.
getCharacterEncoding
())),
outStream
);
writeResponse
(
new
ByteArrayInputStream
(
body
.
getBytes
(
servletResponse
.
getCharacterEncoding
())),
outStream
);
return
;
}
boolean
isGzipRequested
=
false
;
final
String
requestEncoding
=
context
.
getRequest
()
.
getHeader
(
ZuulHeaders
.
ACCEPT_ENCODING
);
final
String
requestEncoding
=
context
.
getRequest
()
.
getHeader
(
ZuulHeaders
.
ACCEPT_ENCODING
);
if
(
requestEncoding
!=
null
&&
HTTPRequestUtils
.
getInstance
().
isGzipped
(
requestEncoding
))
{
...
...
@@ -124,10 +129,12 @@ public class SendResponseFilter extends ZuulFilter {
inputStream
=
new
GZIPInputStream
(
is
);
}
catch
(
java
.
util
.
zip
.
ZipException
ex
)
{
log
.
debug
(
"gzip expected but not "
+
"received assuming unencoded response "
+
RequestContext
.
getCurrentContext
().
getRequest
()
.
getRequestURL
().
toString
());
log
.
debug
(
"gzip expected but not "
+
"received assuming unencoded response "
+
RequestContext
.
getCurrentContext
()
.
getRequest
().
getRequestURL
()
.
toString
());
inputStream
=
is
;
}
}
...
...
@@ -144,7 +151,7 @@ public class SendResponseFilter extends ZuulFilter {
is
.
close
();
}
outStream
.
flush
();
outStream
.
close
();
// The container will close the stream for us
}
catch
(
IOException
ex
)
{
}
...
...
@@ -174,8 +181,8 @@ public class SendResponseFilter extends ZuulFilter {
HttpServletResponse
servletResponse
=
context
.
getResponse
();
List
<
Pair
<
String
,
String
>>
zuulResponseHeaders
=
context
.
getZuulResponseHeaders
();
@SuppressWarnings
(
"unchecked"
)
List
<
String
>
rd
=
(
List
<
String
>)
RequestContext
.
getCurrentContext
()
.
get
(
"routingDebug"
);
List
<
String
>
rd
=
(
List
<
String
>)
RequestContext
.
getCurrentContext
()
.
get
(
"routingDebug"
);
if
(
rd
!=
null
)
{
StringBuilder
debugHeader
=
new
StringBuilder
();
for
(
String
it
:
rd
)
{
...
...
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