As James pointed out in my previous question regarding readLine, for POST requests I will need to read x number of bytes after the headers + blank line with x being determined by the Content-Length header value. My question is this: If I want to use a BufferedReader to read the headers then, after parsing them and seeing the method is POST, can I reuse my socket and create say, a BufferedInputStream to read the binary data (i.e. body) after the blank line, since ultimately they are both derived from the same InputStream produced by the socket OR, will the BufferedInputStream have no idea where the BufferedReader left off and try to read from the beginning?
In James, which handles SMTP (which has the same problem), the following two lines of code work. This is taken from org.apache.james.smtpserver.SMTPHandler.handleConnection(Socket):
in = new BufferedInputStream(socket.getInputStream(), 1024); inReader = new BufferedReader(new InputStreamReader(in, "ASCII"), 512);
The reading alternates, between reading headers from the Reader inReader, and message bodies from the InputStream in. It behaves as desired, always handing the right bytes to in or inReader, although I searched in vain in the API documentation for assurance that it would behave this way.
Rich Hammer
_______________________________________________ Juglist mailing list [EMAIL PROTECTED] http://trijug.org/mailman/listinfo/juglist_trijug.org
