Skip to content

Improve ContentCachingRequestWrapper [SPR-12815] #17412

@spring-projects-issues

Description

@spring-projects-issues

cemo koc opened SPR-12815 and commented

I have an issue with reading inputstream from request multiple times. Before trying an implementation, I have searched in Spring and came across ContentCachingRequestWrapper. This is a nice utility but requires you to have an instance of ContentCachingRequestWrapper to use it as this:

ContentCachingRequestWrapper wrapper = (ContentCachingRequestWrapper) request;
byte[] buf = wrapper.getContentAsByteArray();

This is pretty much limiting because servlet filters are usually wrapping requests into another request instance to provide additional capabilities. I can access this content if only I have an instance of this filter.

It would be great If this behaviour can be changed to provide a new inputstream with cached data.

I have questioned myself why It was not implemented like this in the first place but really could not find a reason.

Shortly, please improve getInputStream and getReader methods to provide cached content in case a consumed stream. Thus we do not need to consider whether request is an instance of ContentCachingRequestWrapper or not.


Affects: 4.1.5

Issue Links:

1 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions