|
From: Ron S. <rs...@re...> - 2012-10-14 05:27:27
|
Hi Remy,
I'm working on RESTEASY-760 "@FormParam does not work with PUT method
when a Query param is present", in which the reporter claims (and I've
verified the behavior), that if he sends a request with both query
parameters and form parameters, Resteasy doesn't pass the form
parameters into his JAX-RS resource. It seems that in jbossweb,
org.apache.catalina.connector.RequestFacade.getParameterMap() returns
only query parameters, despite the javadoc on
javax.servlet.ServletRequest.getParameterMap(), which says
/**
* Returns a java.util.Map of the parameters of this request.
*
* <p>Request parameters are extra information sent with the request.
* For HTTP servlets, parameters are contained in the query string or
* posted form data.
*
* @return an immutable java.util.Map containing parameter names as
* keys and parameter values as map values. The keys in the parameter
* map are of type String. The values in the parameter map are of type
* String array.
*/
1. Is this behavior a bug in jbossweb? I don't see any jbossweb
parameters that override the behavior. Granted, the javadoc is a little
ambiguous, where it says, "parameters are contained in the query string
<em>OR</em> posted form data.
2. Resteasy already has a workaround for Tomcat:
// Tomcat does not set getParameters() if it is a PUT request
// so pull it out manually
if (request.getMethod().equals("PUT") &&
(request.getParameterMap() == null || request.getParameterMap().isEmpty()))
{
return getPutFormParameters();
}
where getPutFormParameters() pulls form parameters directly from the
input stream. I'm thinking of adding this:
Map<String, String[]> parameterMap = request.getParameterMap();
MultivaluedMap<String, String> queryMap = uri.getQueryParameters();
if (mapEquals(parameterMap, queryMap))
{
return getPutFormParameters();
}
In other words, it's a test that request.getParameterMap() contains only
query parameters.
My next question is, is this safe? Is it possible that the input stream
has already been read?
Thanks,
Ron
--
My company's smarter than your company (unless you work for Red Hat).
|