-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Jose,

On 1/14/15 3:54 PM, Jose María Zaragoza wrote:
> 2015-01-14 20:05 GMT+01:00 Christopher Schultz
> <ch...@christopherschultz.net>: Jose,
> 
> On 1/14/15 8:27 AM, Jose María Zaragoza wrote:
>>>> 2015-01-14 12:46 GMT+01:00 André Warnier <a...@ice-sa.com>:
>>>>> Jose María Zaragoza wrote:
>>>>>> 
>>>>>> Hello:
>>>>>> 
>>>>>> I would like to create a web filter to forward some
>>>>>> requests to another webserver,
>>>>>> 
>>>>>> The filter receives an
>>>>>> "application/x-www-form-urlencoded" request , inspects
>>>>>> the value of a parameter and chooses to forward to
>>>>>> another remote webserver ( as a proxy )
>>>> 
>>>> 
>>>> Thanks
>>>> 
>>>> I agree with you . I'll try to use an Apache httpd front-end
>>>> 
>>>> Anyway, I've seen that if I execute
>>>> 
>>>> Map<String, String[]> parameter = ((HttpServletRequest) 
>>>> request).getParameterMap();
>>>> 
>>>> , then request.getInputStream is empty
>>>> 
>>>> 
>>>> But if I execute
>>>> 
>>>> Map<String, String[]> parameter = ((HttpServletRequest) 
>>>> request).getParameterMap(); chain.doFilter(request,
>>>> response);
>>>> 
>>>> , the next filter in the chain receives the body ( as I
>>>> expect it )
>>>> 
>>>> I don't understand this behaviour
> 
> I think that might be a bug... calling 
> HttpServletRequest.getParameter* should cause the request entity to
> be parsed, as long as the content type is 
> application/x-www-form-urlencoded. I think getParameterMap counts,
> but I'd have to review the spec & javadoc (where some fun spec 
> requirements are hidden!).
> 
> Anyhow, when you call HttpServletRequest.getParameter*, the
> container *must* consume the request, according to the spec.
> 
> 
>> Thanks.
> 
>> In my case, all requests to be forwarded are POST requests  (
>> and content type is application/x-www-form-urlencoded ) According
>> to your reply, if I've got a chain of filters and the first one
>> calls getParameterMap , do the next filters lose the content of 
>> the payload ?

Correct. Once the request entity has been read (which happens when you
call request.getParameter*), it's no longer available to the application.

>> I tested to call several times to getParameterMap method on the
>> same webfilter and it always returned the right values. Looks
>> like getParameterMap doesn't consume() payload, but ... if I call
>> getInputStream() after getParameterMap() , the stream is empty
> 
>> I'm using Tomcat 7.0.50 and I cannot understand the logic of
>> this

Interesting. I find that surprising... I'll look into that.

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

iQIcBAEBCAAGBQJUttm6AAoJEBzwKT+lPKRYcSAP/jxIW6s7nsU+aI/XLVW02bxp
Nqb6qkZAVuyvpLRxi6UXDIINR00jb06+ijaz21fLn0F3G0KNQXDPmKi+jcC6zX1P
rB6pJsbfJQYGfkZ0pdF12q+WzFwq1CQbJ4fFlK6WDtKxzoo4XKjlFHwByEPU4yKU
GgyEGX+OD0hIh6nzPyC5pR1iXBLC25f9rsqrlOL+S4sN2MXYLZlHUuBgqN0dOoqH
MN4r5WaaDBQVhadMmi8PScZm3iFMwdjFro7ry4FOuqB5uH6cV6oLIpfzP6F9cTQ2
AUKiL1z6m5VdzsTbtJN0LwqvbILECClcrXJK1OCDL/Uzj04uqCL/+r88mVdjswAJ
lacktHZzF+oPoY2oDDgMAPZTuPlr6nM2D4LETVYpSpUZIGWlJsDmNF/Fe7MAcAo6
ZoC16FSYDTDpEIwXmNzEgWRMn0400DLmdLaS+zO5Sr2h3EI793qVok8Q44yE2Tg8
Um7AdcpBhPzinbXK/OZMoj0YwcBmQDwo4Srdz1hxABc2VG+siCUu1NbwDa3qU+Tx
8Spi1d3Wpnbv2Vuw+1oNnD79EsH1Q3ookRoQTn9B3GDsr7FWs+WZAlSDQERRe+nR
84qswLpAWIC63Geqr3pH4Trsxaa+ge4RX66J8u6vIGYGaxsKJWblqsj02o19Y+O0
hu9eG7FK+q7/+7NR7cj5
=mRkw
-----END PGP SIGNATURE-----

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

Reply via email to