|
From: Ron S. <rs...@re...> - 2012-10-15 17:59:56
|
Ok, I see
> SRV.4.1.1
> When Parameters Are Available
> The following are the conditions that must be met before post form
> data will
> be populated to the parameter set:
> 1. The request is an HTTP or HTTPS request.
> 2. The HTTP method is POST
> 3. The content type is application/x-www-form-urlencoded
> 4. The servlet has made an initial call of any of the getParameter
> family of meth-
> ods on the request object.
> If the conditions are not met and the post form data is not included
> in the
> parameter set, the post data must still be available to the servlet
> via the request
> object’s input stream. If the conditions are met, post form data will
> no longer be
> available for reading directly from the request object’s input stream.
in the Servlet spec. That seems to settle it.
Thanks, Remy.
On 10/15/2012 01:43 PM, Ron Sigal wrote:
> My mistake. I was using PUT when I thought I was using POST. For POST,
> jbossweb returns both the query and the form parameters.
>
> So, I guess the answer is: USE POST. FORGET PUT. Is that reasonable?
>
> Or, I can include my fix that makes it work with PUT. Bill, wdyt?
>
> Sorry for the confusion, Remy. :(
>
> On 10/15/2012 01:25 PM, Ron Sigal wrote:
>> On 10/15/2012 12:12 PM, Rémy Maucherat wrote:
>>> On 10/15/2012 03:40 PM, Bill Burke wrote:
>>>> Please move these types of discussions to the dev list.
>>> Ok, but I am not subscribed to it.
>> WHAT?!?! I thought everyone was on the Resteasy dev list. I'm pretty
>> sure Francois Holland is on the list. Also, Voltaire. But not Marie Le
>> Pen. She's on the jersey dev list. ;)
>>
>>>> But, for form processing, there's a few things you have to worry about.
>>>>
>>>> 1) Did a Servlet filter eat the input stream? You'll need to use
>>>> getParameterMap() then.
>>>> 2) Is it a POST or PUT? If PUT, does getParameterMap() eat the form
>>>> input stream or not?
>>>> 3) If its Tomcat, a PUT, and the filter ate the input stream, you're
>>>> up shit creek.
>>> The spec is quite clear that it deals with URL encoded POSTs, so I
>>> understand the real problems started when other containers thought it
>>> would be nice to ignore specs and do what users asked for. So the
>>> option to also process PUT should be added to AS then ?
>> I'm not sure why the user wants to use PUT. But I get the same problem
>> with POST. Here's my test, on the client side:
>>
>> @Test
>> public void testFormParamWithQueryParamPost() throws Exception
>> {
>> ClientRequest request = new
>> ClientRequest("http://localhost:8080/RESTEASY-760/post/query?query=xyz");
>> request.formParameter("formParam", "abc");
>> request.header("Content-Type", "application/x-www-form-urlencoded");
>> ClientResponse<String> response = request.put(String.class);
>> assertTrue(response != null);
>> System.out.println("response: " + response.getEntity());
>> assertEquals("abc", response.getEntity());
>> }
>>
>> When Resteasy calls
>> javax.servlet.http.HttpServletRequest..getParameterMap(), it gets
>> query=xyz but not formParam=abc. Maybe I'm doing something wrong?
>>
>>> Rémy
>>>
--
My company's smarter than your company (unless you work for Red Hat).
|