Add a method, getContentAsString
, to ContentCachingRequestWrapper
. Having a method directly on ContentCachingRequestWrapper
allows delegating to the toString(Charset)
method of ByteArrayOutputStream
, avoiding an extra copy that calling getContentAsByteArray
and then converting to a String
would.
In practice I've seen a lot of usages of ContentCachingRequestWrapper
where getContentAsByteArray
is called and the returned bytes are immediately decoded to a String
; this method would allow a user to avoid the overhead of the extra copy that incurs.
Comment From: snicoll
Thanks again @kilink