users@glassfish.java.net

Re: I want to test Max Post Size and want to see "Post too large

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Fri, 08 Apr 2011 17:34:26 +0200

Hi Krishan,

> I was trying telnet for testing of connection-upload-timeout, but
> unable to
> test.
>
> Can we connect telnet at localhost, as my web application is running on
> localhost for the time being?
>
> I was trying something like given at
> http://fixunix.com/tcp-ip/66112-re-send-xml-request-server-telnet.html
>
> Is it the right way?
>
> If possible please provide some more details or steps for testing
> connection-upload-timeout.
I've just checked, the upload-timeout forces servlet's InputStream to
return -1, after it expires. So it doesn't throw any Exception.
You can try this servlet code [1].
And do telnet [2] with content [3].

After upload-timeout milliseconds check the Glassfish server.log to see
how much time it took for servlet InputStream to return -1 (end of stream).

Thanks.

WBR,
Alexey.

[1]
     @Override
     protected void doPost(HttpServletRequest request,
HttpServletResponse response)
     throws ServletException, IOException {
         response.setContentType(request.getContentType());

         final InputStream is = request.getInputStream();
         final OutputStream os = response.getOutputStream();

         final long t1 = System.currentTimeMillis();

         byte[] buf = new byte[1024];
         try {
             int len;
             while ((len = is.read(buf)) != -1) {
                 os.write(buf, 0, len);
                 os.flush();
             }

             System.out.println("-1 returned in" + ((int)
((System.currentTimeMillis() - t1) / 1000)) + " seconds");
         } finally {

             is.close();
             os.close();
         }
     }

[2] telnet localhost 8080
[3]
POST /TestServlet/UploadTimeout HTTP/1.1
Host: localhost:8080
Content-length: 5000

AAAAAAAAA


>
> Thanks
>
> Krishan Babbar
>
>
> --
>
> [Message sent by forum member 'babbarkrishan']
>
> View Post: http://forums.java.net/node/788284
>
>