(int streamId, int flags, int payloadSize, ByteBuffer buffer)
| 133 | } |
| 134 | |
| 135 | protected void readDataFrame(int streamId, int flags, int payloadSize, ByteBuffer buffer) |
| 136 | throws Http2Exception, IOException { |
| 137 | // Process the Stream |
| 138 | int padLength = 0; |
| 139 | |
| 140 | boolean endOfStream = Flags.isEndOfStream(flags); |
| 141 | |
| 142 | int dataLength; |
| 143 | if (Flags.hasPadding(flags)) { |
| 144 | |
| 145 | // Frame is too small to contain mandatory frame data (for the given flags) |
| 146 | if (payloadSize == 0) { |
| 147 | throw new ConnectionException(sm.getString("http2Parser.processFrame.insufficientPayload",connectionId, |
| 148 | Integer.toString(streamId), Integer.toString(FrameType.DATA.getId()), |
| 149 | Integer.toString(flags), Integer.toString(payloadSize)), Http2Error.FRAME_SIZE_ERROR); |
| 150 | } |
| 151 | |
| 152 | if (buffer == null) { |
| 153 | byte[] b = new byte[1]; |
| 154 | input.fill(true, b); |
| 155 | padLength = b[0] & 0xFF; |
| 156 | } else { |
| 157 | padLength = buffer.get() & 0xFF; |
| 158 | } |
| 159 | |
| 160 | if (padLength >= payloadSize) { |
| 161 | throw new ConnectionException( |
| 162 | sm.getString("http2Parser.processFrame.tooMuchPadding", connectionId, |
| 163 | Integer.toString(streamId), Integer.toString(padLength), Integer.toString(payloadSize)), |
| 164 | Http2Error.PROTOCOL_ERROR); |
| 165 | } |
| 166 | // +1 is for the padding length byte we just read above |
| 167 | dataLength = payloadSize - (padLength + 1); |
| 168 | } else { |
| 169 | dataLength = payloadSize; |
| 170 | } |
| 171 | |
| 172 | if (log.isTraceEnabled()) { |
| 173 | String padding; |
| 174 | if (Flags.hasPadding(flags)) { |
| 175 | padding = Integer.toString(padLength); |
| 176 | } else { |
| 177 | padding = "none"; |
| 178 | } |
| 179 | log.trace(sm.getString("http2Parser.processFrameData.lengths", connectionId, Integer.toString(streamId), |
| 180 | Integer.toString(dataLength), padding)); |
| 181 | } |
| 182 | |
| 183 | ByteBuffer dest; |
| 184 | try { |
| 185 | dest = output.startRequestBodyFrame(streamId, dataLength, endOfStream); |
| 186 | } catch (StreamException se) { |
| 187 | swallowPayload(streamId, FrameType.DATA.getId(), dataLength, false, buffer); |
| 188 | if (Flags.hasPadding(flags)) { |
| 189 | swallowPayload(streamId, FrameType.DATA.getId(), padLength, true, buffer); |
| 190 | } |
| 191 | throw se; |
| 192 | } |
no test coverage detected