You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Nathan Ashworth <na...@yahoo.com> on 2009/01/13 18:14:29 UTC

How to handle Expect: 100-continue

What's the simplest way to support Expect: 100-continue requests in a servlet
running on Tomcat 6?

My current solution is to look for the "expect" header, check whether its
value is "100-continue" and if it is, then I get a BufferedReader from the
request [request.getReader()] and dump the contents into a String. I then
parse that String into a parameter Map.

Now, this does work, but it feels like I am doing work that Tomcat should be
handling transparently. Am I missing something here?

Thanks,

Nathan
-- 
View this message in context: http://www.nabble.com/How-to-handle-Expect%3A-100-continue-tp21440164p21440164.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: How to handle Expect: 100-continue

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
That is how it is with every single request.
Tomcat will never read a body unless the servlet initiates the action.
So to read a body you can either
- read the input stream
- read the reader
- issue a request.getParameter (if the body is form encoded, tomcat will 
read the body and parse the parameters)

I'm not sure what the Expect/100-continue headers have anything to do 
with reading the body.
As a servlet/JSP developers, you are the trigger for reading the body, 
without any exceptions.

Filip


Nathan Ashworth wrote:
> What we are observing is: 1) Client initiates the POST with the 'Expect:
> 100-continue' header, 2) Tomcat responds with '100 Continue', 3) Tomcat
> calls the servlet. Now once we are in our servlet, unless we explicitly read
> from the request's BufferedReader, the client will not send the remainder of
> the POST.
>
> So, from my perspective, it looks like Tomcat is only handling half of the
> POST, while it is up to to servlet to read and parse the other half. Is that
> the expected process when dealing with 100-continue?
>
>
> Filip Hanik - Dev Lists wrote:
>   
>> if you use wireshark, you should see that Tomcat already does it 
>> automatically.
>> if you look at the code StandardWrapperValve.java, it should call 
>> response.acknowledge(), and if the client sent an expect header, tomcat 
>> will write out the 100 continue
>> Filip
>>
>> Nathan Ashworth wrote:
>>     
>>> What's the simplest way to support Expect: 100-continue requests in a
>>> servlet
>>> running on Tomcat 6?
>>>
>>> My current solution is to look for the "expect" header, check whether its
>>> value is "100-continue" and if it is, then I get a BufferedReader from
>>> the
>>> request [request.getReader()] and dump the contents into a String. I then
>>> parse that String into a parameter Map.
>>>
>>> Now, this does work, but it feels like I am doing work that Tomcat should
>>> be
>>> handling transparently. Am I missing something here?
>>>
>>> Thanks,
>>>
>>> Nathan
>>>   
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>>     
>
>   


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


Re: How to handle Expect: 100-continue

Posted by Nathan Ashworth <na...@yahoo.com>.
What we are observing is: 1) Client initiates the POST with the 'Expect:
100-continue' header, 2) Tomcat responds with '100 Continue', 3) Tomcat
calls the servlet. Now once we are in our servlet, unless we explicitly read
from the request's BufferedReader, the client will not send the remainder of
the POST.

So, from my perspective, it looks like Tomcat is only handling half of the
POST, while it is up to to servlet to read and parse the other half. Is that
the expected process when dealing with 100-continue?


Filip Hanik - Dev Lists wrote:
> 
> if you use wireshark, you should see that Tomcat already does it 
> automatically.
> if you look at the code StandardWrapperValve.java, it should call 
> response.acknowledge(), and if the client sent an expect header, tomcat 
> will write out the 100 continue
> Filip
> 
> Nathan Ashworth wrote:
>> What's the simplest way to support Expect: 100-continue requests in a
>> servlet
>> running on Tomcat 6?
>>
>> My current solution is to look for the "expect" header, check whether its
>> value is "100-continue" and if it is, then I get a BufferedReader from
>> the
>> request [request.getReader()] and dump the contents into a String. I then
>> parse that String into a parameter Map.
>>
>> Now, this does work, but it feels like I am doing work that Tomcat should
>> be
>> handling transparently. Am I missing something here?
>>
>> Thanks,
>>
>> Nathan
>>   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-handle-Expect%3A-100-continue-tp21440164p21443700.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: How to handle Expect: 100-continue

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
if you use wireshark, you should see that Tomcat already does it 
automatically.
if you look at the code StandardWrapperValve.java, it should call 
response.acknowledge(), and if the client sent an expect header, tomcat 
will write out the 100 continue
Filip

Nathan Ashworth wrote:
> What's the simplest way to support Expect: 100-continue requests in a servlet
> running on Tomcat 6?
>
> My current solution is to look for the "expect" header, check whether its
> value is "100-continue" and if it is, then I get a BufferedReader from the
> request [request.getReader()] and dump the contents into a String. I then
> parse that String into a parameter Map.
>
> Now, this does work, but it feels like I am doing work that Tomcat should be
> handling transparently. Am I missing something here?
>
> Thanks,
>
> Nathan
>   


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


Re: How to handle Expect: 100-continue

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
Nathan Ashworth wrote:
> Thanks, Filip.
>
> Upon further investigation, we've discovered that our POSTs were bigger than
> the default maxPostSize value (2MB). The call to getParameter("foo") was
> returning null and doing a trace showed that the client was not sending the
> body.
>   
good catch
> It appears that Tomcat is returning "100 Continue" immediately, and then
> when it starts to read the body [as part of getParameter()] it notices that
> Content-Length is greater than maxPostSize and it skips the body.
>   
ack happens right away, regardless of body.
> Wouldn't it be better if Tomcat looked at the Content-Length before it
> acknowledges the request? Maybe reply with a 417 instead?
>   
not sure why it would not ack the request. its gonna do that everytime.
However, if the knows that the body wont fit, it could throw an 
exception to the app, so that one knows what went wrong.

you can always open a bug or enhancement request in bugzilla
https://issues.apache.org/bugzilla/index.cgi

Filip



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


Re: How to handle Expect: 100-continue

Posted by Nathan Ashworth <na...@yahoo.com>.
Thanks, Filip.

Upon further investigation, we've discovered that our POSTs were bigger than
the default maxPostSize value (2MB). The call to getParameter("foo") was
returning null and doing a trace showed that the client was not sending the
body.

It appears that Tomcat is returning "100 Continue" immediately, and then
when it starts to read the body [as part of getParameter()] it notices that
Content-Length is greater than maxPostSize and it skips the body.

Wouldn't it be better if Tomcat looked at the Content-Length before it
acknowledges the request? Maybe reply with a 417 instead?

-- 
View this message in context: http://www.nabble.com/How-to-handle-Expect%3A-100-continue-tp21440164p21445613.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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