You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christian Kindler <ch...@kruescho.de> on 2008/03/07 09:22:32 UTC
interrupting a multipart post request?
Hello,
I'm not sure if this is tomcat or general servlet issue. I hope you can
help me anyway.
I want to interrupt a multipart post request (e.g. if the content-length
exceeds a given limit). The problem is, that the client seems to
continue sending the data to the server and gets no response from the
server until the whole data is send.
Please see the following doPost method. On the console the exception
appears immediately, but a takes much longer until I can see the
response in the browser.
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
if (request.getContentLength() > 1000000) {
throw new ServletException("request limit exceeded.");
}
}
The same thing if I try to forward the request via the
RequestDispatcher: the request is forwarded when the whole data is sent
to the server and not immediately.
I am using Tomcat 6.0.16 with jdk 1.6.0_04 on windows xp.
Regards,
Christian
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: %t in access log valve?
Posted by Mark Thomas <ma...@apache.org>.
Dan Keeley wrote:
> Hi all,
>
> Just a quick one; It's not clear from the docs.
>
> is %t in the accessLogValve the request datetime or the response datetime?
>
> It makes a difference to us!
>
> thanks,
> Dan
When starting a new thread (ie sending a message to the list about a
new topic) please do not reply to an existing message and change the
subject line. This is known as thread hijacking and to many of the
list archiving services and mail clients used by list subscribers this
makes your new message appear as part of the old thread. This makes it
harder for other users to find relevant information when searching the
lists.
It should also be noted that many list subscribers automatically
ignore any messages that hijack another thread.
The correct procedure is to create a new message with a new subject.
This will start a new thread.
Thanks,
Mark
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
%t in access log valve?
Posted by Dan Keeley <li...@dankeeley.co.uk>.
Hi all,
Just a quick one; It's not clear from the docs.
is %t in the accessLogValve the request datetime or the response datetime?
It makes a difference to us!
thanks,
Dan
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: interrupting a multipart post request?
Posted by Christian Kindler <ch...@kruescho.de>.
Christopher Schultz wrote:
> Christian Kindler wrote:
> | Maybe it's a good question for tomcat-dev...
>
> Agreed. Post back if you find a solution.
The only answer I got on tomcat-dev is the following one. So it really
seems to be a protocol problem...
Rick Knowles wrote:
> Christian,
>
> Unfortunately due to request pipelining (the norm in HTTP/1.1), any
> attempt to send an error message or abort just results in the container
> having to silently consume the body of the upload anyway. The next
> request in the pipeline after a medium size upload could even
> conceivably be in the same TCP packet, so the container has to consume
> every request to make sure it correctly locates the start of the next
> request.
>
> It isn't worth even trying to handle - it's a necessary evil, the
> flipside of the taken-for-granted speed boosts that request pipelining
> brings.
>
> Rick
>
> Christian Kindler wrote:
>> Hi all,
>>
>> there seems to be no possibility to immediately cancel a (multipart)
>> post request (for example if the content-length exceeds a certain
>> limit). Whatever I do in a servlet's doPost method (throwing an
>> exception, closing the request's stream, interrupting the current
>> thread), the client continues sending the data to the server.
>> So there is nothing I can do to prevent users from sending huge amount
>> if data to the server and producing a lot of traffic.
>>
>> All I want to do is to cancel a request immediately. I don't care if
>> the client get's a reasonable error message or if the connection
>> remains or not. Is there any way to achieve this or is it a general
>> problem of the HTTP protocol?
>>
>> I hope it's o.k. that I ask this question here, on the users list
>> unfortunately nobody could help or explain the reasons for this
behavior.
>>
>> Christian
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: interrupting a multipart post request?
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Christian,
Christian Kindler wrote:
| Maybe it's a good question for tomcat-dev...
Agreed. Post back if you find a solution.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkfakgQACgkQ9CaO5/Lv0PBvugCgjf0mgQNh+dKQ74yAt3/0lJv5
PUcAn39Ns7BUDuGHh+AkHSgG8jVtcwtv
=mCKK
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: interrupting a multipart post request?
Posted by Christian Kindler <ch...@kruescho.de>.
Christopher Schultz wrote:
> Christian Kindler wrote:
> | Is something like Thread.currentThread().interrupt() the only way to
> | stop a multipart post request?
>
> I'm pretty sure you don't want to do that. The javadoc for
> Thread.interrupt states that any blocked I/O calls will be aborted, but
> you never know what Tomcat will do in that case.
>
> You might want to check out the thread-handling code in Tomcat to see
> what happens, or re-post with /that/ question to see what some of the
> old salts have to say about it.
Hi Chris,
Thread.currentThread().interrupt() does not work anyway. I don't know if
it is a Tomcat problem or a generall problem of the HTTP protocol.
Maybe it's a good question for tomcat-dev...
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: interrupting a multipart post request?
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Christian,
Christian Kindler wrote:
| Is something like Thread.currentThread().interrupt() the only way to
| stop a multipart post request?
I'm pretty sure you don't want to do that. The javadoc for
Thread.interrupt states that any blocked I/O calls will be aborted, but
you never know what Tomcat will do in that case.
You might want to check out the thread-handling code in Tomcat to see
what happens, or re-post with /that/ question to see what some of the
old salts have to say about it.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkfai9wACgkQ9CaO5/Lv0PDCvACgqJxTekwjCNm7Iyl44IbZN40f
C20An0XxYsg70dZZqFMLWugKogRcu3fu
=hhhK
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: interrupting a multipart post request?
Posted by Christian Kindler <ch...@kruescho.de>.
Christian Kindler schrieb:
> Christopher Schultz schrieb:
>> Christian Kindler wrote:
>> | I want to interrupt a multipart post request (e.g. if the
>> content-length
>> | exceeds a given limit). The problem is, that the client seems to
>> | continue sending the data to the server and gets no response from the
>> | server until the whole data is send.
>>
>> Maybe try this:
>>
>> ~ if (request.getContentLength() > 1000000) {
>> ~ request.getInputStream().close();
>>
>> ~ throw new ServletException("request limit exceeded.");
>> ~ }
>>
>> ...or some variant thereof.
>
> Hello Christopher,
>
> that works, thanks!
Sorry, I was a little bit headily. Ist does not work.
Is something like Thread.currentThread().interrupt() the only way to
stop a multipart post request?
Regards, Christian
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: interrupting a multipart post request?
Posted by Christian Kindler <ch...@kruescho.de>.
Christopher Schultz schrieb:
> Christian Kindler wrote:
> | I want to interrupt a multipart post request (e.g. if the content-length
> | exceeds a given limit). The problem is, that the client seems to
> | continue sending the data to the server and gets no response from the
> | server until the whole data is send.
>
> Maybe try this:
>
> ~ if (request.getContentLength() > 1000000) {
> ~ request.getInputStream().close();
>
> ~ throw new ServletException("request limit exceeded.");
> ~ }
>
> ...or some variant thereof.
Hello Christopher,
that works, thanks!
Regards,
Christian
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: interrupting a multipart post request?
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Christian,
Christian Kindler wrote:
| I want to interrupt a multipart post request (e.g. if the content-length
| exceeds a given limit). The problem is, that the client seems to
| continue sending the data to the server and gets no response from the
| server until the whole data is send.
[snip]
| public void doPost(HttpServletRequest request, HttpServletResponse
| response)
| throws ServletException, IOException {
| if (request.getContentLength() > 1000000) {
| throw new ServletException("request limit exceeded.");
| }
| }
Maybe try this:
~ if (request.getContentLength() > 1000000) {
~ request.getInputStream().close();
~ throw new ServletException("request limit exceeded.");
~ }
...or some variant thereof.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkfR/X0ACgkQ9CaO5/Lv0PBJygCguQsz7f87pxZwKsdY+wloQMCi
zaQAn1jn6Wuxrvzt4WV5skm4F8+OS6D6
=WHLf
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org