You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Teunissen,Peter" <Pe...@Cerner.com> on 2015/05/28 21:44:59 UTC

Tomcat Valve doing Request.getParameter() consumes the stream

(Tomcat 7)

I am writing a Valve that does a getParameter on the Request. At the end of the Valve/Filter chain is a servlet that calls HttpServletRequest.getReader() returning an empty buffer (because the Valve consumed it).

I tried hacking a wrapper for the Request together and pass that into the getNext().invoke , but not much luck yet (seems to be some state in the underlying coyoteStream/Request/Inputbuffer....)

I can't imagine I'm the first to encounter this and yet I can't find a good wrapper example on the internet.

Anybody better suggestions?


CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.

Re: Tomcat Valve doing Request.getParameter() consumes the stream

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Peter,

On 5/28/15 3:44 PM, Teunissen,Peter wrote:
> (Tomcat 7)
> 
> I am writing a Valve that does a getParameter on the Request. At
> the end of the Valve/Filter chain is a servlet that calls
> HttpServletRequest.getReader() returning an empty buffer (because
> the Valve consumed it).
> 
> I tried hacking a wrapper for the Request together and pass that
> into the getNext().invoke , but not much luck yet (seems to be some
> state in the underlying coyoteStream/Request/Inputbuffer....)
> 
> I can't imagine I'm the first to encounter this and yet I can't
> find a good wrapper example on the internet.
> 
> Anybody better suggestions?

You might be able to adapt this Filter I wrote to do the same thing:

http://markmail.org/thread/fumpfuspt7a3nesz

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJVaLkcAAoJEBzwKT+lPKRYZegP/RJ3bJe2aZh2LGkXYjSCb1wn
KUdkscj0PrpT4uRMNDsoLkBMhzzJc33EjUNvlz60eNjUh0hL/PZ2aIV0suxJ+g83
KeziNOah6goaiJ77PgyyV9MFx76T24EvTgQPRAgKUrN84cbk8uGQ/iY2rBrM4A+7
CDUUEOHTb5oLq/s/oEEEDdC06XXCY/O03p+5WMPb5StEvYr2f8Iipa6AX7sYxlDT
D7i5z4kJnR4iYWmz7tU0FP7c0R0n5Mxz/alpoiydv2Gnfxb9wNY6wdge4td5fwIO
/QXqDGb/nDA7dpvzTYMQq8Fozi6sjxV7z6Au7P19TFQxbKBjYq5LEyh7B4FD88nO
QKuW8uyTcz0A028XWuy2Vu61LE5uGuHllXOrQjycZsTeH3FIyxJ5gRsKtlhxSrNw
2MVS2FxAG7J3mvM+RDMsethJsfAmF3p3CM3UeOB70vOghBnkPl5fHThJ2uwle6YT
yoy8n91Ls+ErWo+JFhHM5KTrX29MrT7l8berUSIhsMS5p1rw8Qu3WlIF4UT406yo
4LVPYSBfnem5aJa1Zfcc/fWVoWzNOeOUgpgsV2B2bPPSm2yBBtyAli2q+BGRBwSb
vtddKILo+RkujAId5OIFAfluw+nuiBqAGTBQRKc4pKFB7yIOmmuUH/a3E689jaCj
vtFSyy0acGimDfmQyXAE
=QES6
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat Valve doing Request.getParameter() consumes the stream

Posted by Violeta Georgieva <mi...@gmail.com>.
Hi,

2015-05-28 22:44 GMT+03:00 Teunissen,Peter <Pe...@cerner.com>:
>
> (Tomcat 7)
>
> I am writing a Valve that does a getParameter on the Request. At the end
of the Valve/Filter chain is a servlet that calls
HttpServletRequest.getReader() returning an empty buffer (because the Valve
consumed it).
>
> I tried hacking a wrapper for the Request together and pass that into the
getNext().invoke , but not much luck yet (seems to be some state in the
underlying coyoteStream/Request/Inputbuffer....)
>
> I can't imagine I'm the first to encounter this and yet I can't find a
good wrapper example on the internet.
>
> Anybody better suggestions?

You may want to check this enhancement [1].

Regards,
Violeta

[1] https://bz.apache.org/bugzilla/show_bug.cgi?id=45014
>
>
> CONFIDENTIALITY NOTICE This message and any included attachments are from
Cerner Corporation and are intended only for the addressee. The information
contained in this message is confidential and may constitute inside or
non-public information under international, federal, or state securities
laws. Unauthorized forwarding, printing, copying, distribution, or use of
such information is strictly prohibited and may be unlawful. If you are not
the addressee, please promptly delete this message and notify the sender of
the delivery error by e-mail or you may call Cerner's corporate offices in
Kansas City, Missouri, U.S.A at (+1) (816)221-1024.