tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David kerber <>
Subject Re: Peformance on socket reads
Date Fri, 15 May 2009 16:22:51 GMT
Christopher Schultz wrote:
> Hash: SHA1
> David,
> On 5/14/2009 8:34 AM, David kerber wrote:
>>   len = req.getContentLength();
>>   b = new byte[ len ];
> Don't forget to check to see if getContentLength() returned zero.
I do, it's just not in that code snippet.
> What is the content-type here? Is it application/x-www-form-urlencoded?
> Are you calling req.getParameter() or any of the same family of
> functions? If both of those are true, then Tomcat has already read the
> body of the request, and you won't be able to re-read it.
I don't recall the content-type off the top of my head (and I don't have 
the source of the sending app at hand), and I don't use 
req.getParameter() at all.  But the code works; it just seems to be a 
little slow.

>>   iStream = req.getInputStream();
>>    /* this is the line 198 that the above thread dump is waiting for: */
>>   strLen = b, 0, len );
>>   iStream.close();
> If you want a String, why not use req.getReader() instead of
> req.getInputStream()?
At this point, it's still encrypted, and a string may not properly 
handle some of the bytes.  I don't make it a string until I'm done 
decrypting it (forgot to mention that point in my original post).

> I think you may have better luck reading until there is no more input,
What method would you suggest?  Create the byte array long enough to 
handle any possible input and then read without specifying the length?

> rather than relying upon the Content-Length matching the available data
> (which really /should/ work, but obviously something else is happening
> here).


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message