BufferedReader.readLine() blocks unexpected
I have a method where i will handle an Input/Output Stream from a
ServerSocket. The Client sends several requests and these should be
handled in one connection.
The first request is handled as expected but the seconds request is
blocked by the requestReader.readLine() method... According to JavaDoc
i cant find anything about readLine() blocking.
Has anybody a clue what could be wrong here?
--
public void handleRequest() throws IOException {
BufferedReader requestReader = new BufferedReader(new
InputStreamReader(socket.getInputStream));
OutputStream responseStream = new
BufferedOutputStream(socket.getOutputStream());
do {
Request request = new Request();
Response response = new Response();
parseRequest(requestReader, request);
processRequest(request, response);
writeResponse(responseStream, response);
}while(keepAlive && !hasError);
request.close();
response.close();
socket.close();
}
private void parseRequest(HttpRequest request) throws IOException {
String reqString = requestReader.readLine();
//.. do something with String here
//Read on
while(requestReader.ready()) {
String reqHeaders = requestReader.readLine();
//Reached end?
if(reqHeaders == null || reqHeaders.length() == 0) {
break;
}
//.. do something with String here
}
}
--