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
c795bd16
Commit
c795bd16
authored
Feb 10, 2017
by
Roman Terentiev
Committed by
Spencer Gibb
Feb 10, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1203 Improve filter performance by using only one instance of…
#1203 Improve filter performance by using only one instance of AllEncompassingFormHttpMessageConverter (#1681)
parent
7237275f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
FormBodyWrapperFilter.java
...cloud/netflix/zuul/filters/pre/FormBodyWrapperFilter.java
+8
-3
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/pre/FormBodyWrapperFilter.java
View file @
c795bd16
...
...
@@ -31,6 +31,7 @@ import org.springframework.http.HttpHeaders;
import
org.springframework.http.HttpOutputMessage
;
import
org.springframework.http.InvalidMediaTypeException
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.converter.FormHttpMessageConverter
;
import
org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter
;
import
org.springframework.util.Assert
;
import
org.springframework.util.MultiValueMap
;
...
...
@@ -52,10 +53,16 @@ import static org.springframework.cloud.netflix.zuul.filters.support.FilterConst
*/
public
class
FormBodyWrapperFilter
extends
ZuulFilter
{
private
FormHttpMessageConverter
formHttpMessageConverter
;
private
Field
requestField
;
private
Field
servletRequestField
;
public
FormBodyWrapperFilter
()
{
this
(
new
AllEncompassingFormHttpMessageConverter
());
}
public
FormBodyWrapperFilter
(
FormHttpMessageConverter
formHttpMessageConverter
)
{
this
.
formHttpMessageConverter
=
formHttpMessageConverter
;
this
.
requestField
=
ReflectionUtils
.
findField
(
HttpServletRequestWrapper
.
class
,
"req"
,
HttpServletRequest
.
class
);
this
.
servletRequestField
=
ReflectionUtils
.
findField
(
ServletRequestWrapper
.
class
,
...
...
@@ -139,8 +146,6 @@ public class FormBodyWrapperFilter extends ZuulFilter {
private
int
contentLength
;
private
AllEncompassingFormHttpMessageConverter
converter
=
new
AllEncompassingFormHttpMessageConverter
();
public
FormBodyRequestWrapper
(
HttpServletRequest
request
)
{
super
(
request
);
this
.
request
=
request
;
...
...
@@ -184,7 +189,7 @@ public class FormBodyWrapperFilter extends ZuulFilter {
this
.
contentType
=
MediaType
.
valueOf
(
this
.
request
.
getContentType
());
data
.
getHeaders
().
setContentType
(
this
.
contentType
);
this
.
c
onverter
.
write
(
builder
,
this
.
contentType
,
data
);
FormBodyWrapperFilter
.
this
.
formHttpMessageC
onverter
.
write
(
builder
,
this
.
contentType
,
data
);
// copy new content type including multipart boundary
this
.
contentType
=
data
.
getHeaders
().
getContentType
();
this
.
contentData
=
data
.
getInput
();
...
...
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