Re: interrupting a multipart post request?

2008-03-25 Thread Christian Kindler

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: interrupting a multipart post request?

2008-03-14 Thread Christian Kindler

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()  100) {
~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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: interrupting a multipart post request?

2008-03-14 Thread Christian Kindler

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: interrupting a multipart post request?

2008-03-10 Thread Christian Kindler

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()  100) {
~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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



interrupting a multipart post request?

2008-03-07 Thread Christian Kindler

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()  100) {
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]