Code with Finding: |
class HttpRequestMessage { /** * @return A boolean <strong>true</strong> if the MIME parser should stop * parsing, <strong>false</strong> otherwise. * @exception IOException If some IO error occured while reading the * stream. * @exception HttpParserException if parsing failed. */ public boolean notifyBeginParsing(MimeParser parser) throws HttpParserException, IOException { // Append the whole reply line in some buffer: HttpBuffer buf = new HttpBuffer(); int ch = parser.read(); // A present for Netscape ! while((ch == '\r') || (ch == '\n')) ch = parser.read(); loop: while (true) { switch(ch) { case -1: throw new HttpParserException("End Of File"); case '\r': if ((ch = parser.read()) != '\n') parser.unread(ch); break loop; case '\n': break loop; default: buf.append(ch); } ch = parser.read(); } // Parse the bufer into HTTP version and status code byte line[] = buf.getByteCopy(); ParseState ps = new ParseState(); ps.ioff = 0; ps.bufend = line.length; ps.separator = (byte) ' '; // Get the method name: if ( HttpParser.nextItem(line, ps) < 0 ) throw new RuntimeException("Bad request, no method !"); setMethod(ps.toString(line)); // Get the URL path, or full URL if ( HttpParser.nextItem(line, ps) < 0 ) throw new RuntimeException("Bad request, no URL !"); setTarget(ps.toString(line)); // Get the version numbers: HttpParser.skipSpaces(line, ps); if ( ps.ioff + 5 < ps.bufend ) { ps.ioff += 5; ps.separator = (byte) '.'; this.major = (short) HttpParser.parseInt(line, ps); ps.prepare(); this.minor = (short) HttpParser.parseInt(line, ps); return false; } else { this.major = 0; this.minor = 9; return true; } }
}
|