You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2002/01/31 06:19:20 UTC
DO NOT REPLY [Bug 6141] New: -
read() function failing in HttpServletRequest InputStream
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6141>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6141
read() function failing in HttpServletRequest InputStream
Summary: read() function failing in HttpServletRequest
InputStream
Product: Tomcat 4
Version: 4.0 Beta 1
Platform: Other
OS/Version: Linux
Status: NEW
Severity: Normal
Priority: Other
Component: Catalina
AssignedTo: tomcat-dev@jakarta.apache.org
ReportedBy: dknowles@clearfield.com
There definitely appears to be an error in the InputStream which is gained from
the HttpServletRequest.
If the bytes are read from the data stream using the read function it returns
bytes larger than 127 as negative values i.e. as for signed bytes. This is a
direct contravention of the JDK specification which states that these values
should be in the range of 0 to 255.
This has a flow on effect on other functions. For example if a stream of bytes
is received by the stream the other read functions will read to the first value
which is hex 0xFF and then falsly indicate that the stream is closed.
I have briefly looked at the code and cannot fault it however the return of the
read value is clearly -ve.
I believe this may be why Bug 5827 is occuring.
Code snipit in the servlet which exhibits this behaviour
byte [] byteBuff = new byte [ 4096 ] ;
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
// Get the input stream from the request
InputStream in = request.getInputStream ( ) ;
// Tell the log what the data length is
log ( "Content Available bytes: " + request.getContentLength() ) ;
// Read the data into the buffer
readInputSingly ( in, byteBuff, request.getContentLength() ) ;
}
protected void readInputSingly ( InputStream input, byte [] data, int
dataLength ) throws java.io.IOException
{
int offset = 0 ;
int dataByte ;
log ( "Reading bytes" ) ;
while ( offset < dataLength )
{
dataByte = input.read ( ) ;
if ( (dataByte < 0) )
{
log ( "The data value is negative: " + dataByte ) ;
} else
{
log ( "Byte: " + Integer.toHexString ( dataByte ) ) ;
data [ offset ] = (byte)dataByte ;
offset ++ ;
}
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>