Read an AJP message. @param message The message to populate @param block If there is no data available to read when this method is called, should this call block until data becomes available? @return true if the message has been read, false if no data was read @throws IOExcep
(AjpMessage message, boolean block)
| 561 | * @throws IOException any other failure, including incomplete reads |
| 562 | */ |
| 563 | private boolean readMessage(AjpMessage message, boolean block) throws IOException { |
| 564 | |
| 565 | byte[] buf = message.getBuffer(); |
| 566 | |
| 567 | if (!read(buf, 0, Constants.H_SIZE, block)) { |
| 568 | return false; |
| 569 | } |
| 570 | |
| 571 | int messageLength = message.processHeader(true); |
| 572 | if (messageLength < 0) { |
| 573 | // Invalid AJP header signature |
| 574 | throw new IOException(sm.getString("ajpmessage.invalidLength", Integer.valueOf(messageLength))); |
| 575 | } else if (messageLength == 0) { |
| 576 | // Zero length message. |
| 577 | return true; |
| 578 | } else { |
| 579 | if (messageLength > (buf.length - Constants.H_SIZE)) { |
| 580 | // Message too long for the buffer |
| 581 | // Need to trigger a 400 response |
| 582 | String msg = sm.getString("ajpprocessor.header.tooLong", Integer.valueOf(messageLength), |
| 583 | Integer.valueOf(buf.length)); |
| 584 | log.error(msg); |
| 585 | throw new IllegalArgumentException(msg); |
| 586 | } |
| 587 | read(buf, Constants.H_SIZE, messageLength, true); |
| 588 | return true; |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | |
| 593 | /** |