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

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. If you want to
pull-in the request entity, you'll have to read it yourself using
HttpServletRequest.getInputStream / HttpServletRequest.getReader. That
means parsing it yourself, buffering it yourself, etc. You also get to
wrap the request and re-supply the buffered request to the local web
application should you choose to process it locally instead of proxy
it remotely.

Also note that Tomcat supplies some response headers itself that
cannot be overridden, so you can't be a completely-transparent reverse
proxy. Keep that in mind if you decide to go down this road...

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

iQIcBAEBCAAGBQJUtr3zAAoJEBzwKT+lPKRYDzkP/1XM5y72x41YBG56xgcvzsV6
wQ1S5TLuEvzPGPBAR7sFWv+qCeZecIJ9WvkBTgaKiPm4Dn8rxLCvf34yaNTsHg7P
D0POXQrON36lZmUfg9utIySv4L0Y88MCFpdEkJr38ENTOK7bhAGsNK6kITeR2rXJ
z8XOOmMVgMYSGKqbUK3gbBKpifdr0fuSobcDPnJkOv751e63/jMzf0IBI2z3tQhe
xsXEd3JaCjguzOIXBCgbXaZUxEk3EgBjHm3xlHX1GEYSIwr/PHqyTtK4a82r25Ny
dhWbMsQc8hV018helpTVPj9ae0IUQXaDTsP+aXgXOwrzKXu1pLpMGeXjery54uwY
gJG32tMfNKLVikiq5xIKBHObzplei/jHjDn66w9Z0W3SZiGhtg9xDynpgqFPxKHY
iv/m5bwO0jPEUU7Yq99uu+jMwfJJDIWtWSKKrQ3IzmxJ6uNsiPhKX2jfTUn3wJ19
9q9ur/fER9nB9q4GAjUUVVe07Z4NH9ofPvXTKJExklpH64nCx99zmBYqXcLdsaxb
2uGJcl6bu7sKWm0GzL7+kSnvFhOfkfM9mDoVgNbxKyJEHRcurA91PL2DguEOuUtV
g9pXrY+Sfd2siq2K1O1TX7wPOebNc/HFIWPux6rtGXB8/pc3XPhaM2UwlxpHfLzp
YyN10GOrc+HacHHbtwHs
=vczy
-----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