()
| 378 | * Reads a message from the server. |
| 379 | */ |
| 380 | public TesterAjpMessage readMessage() throws IOException { |
| 381 | |
| 382 | InputStream is = socket.getInputStream(); |
| 383 | |
| 384 | TesterAjpMessage message = new TesterAjpMessage(packetSize); |
| 385 | |
| 386 | byte[] buf = message.getBuffer(); |
| 387 | |
| 388 | read(is, buf, 0, Constants.H_SIZE); |
| 389 | |
| 390 | int messageLength = message.processHeader(false); |
| 391 | if (messageLength < 0) { |
| 392 | throw new IOException("Invalid AJP message length"); |
| 393 | } else if (messageLength == 0) { |
| 394 | return message; |
| 395 | } else { |
| 396 | if (messageLength > buf.length) { |
| 397 | throw new IllegalArgumentException("Message too long [" + Integer.valueOf(messageLength) + |
| 398 | "] for buffer length [" + Integer.valueOf(buf.length) + "]"); |
| 399 | } |
| 400 | read(is, buf, Constants.H_SIZE, messageLength); |
| 401 | return message; |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | protected boolean read(InputStream is, byte[] buf, int pos, int n) throws IOException { |
| 406 |
no test coverage detected