Read chunked post body. @return the post body as a bytes array @throws IOException if an IO exception occurred
()
| 3141 | * @throws IOException if an IO exception occurred |
| 3142 | */ |
| 3143 | protected byte[] readChunkedPostBody() throws IOException { |
| 3144 | ByteChunk body = new ByteChunk(); |
| 3145 | |
| 3146 | byte[] buffer = new byte[CACHED_POST_LEN]; |
| 3147 | |
| 3148 | int len = 0; |
| 3149 | while (len > -1) { |
| 3150 | len = getStream().read(buffer, 0, CACHED_POST_LEN); |
| 3151 | if (connector.getMaxPostSize() >= 0 && ((long) body.getLength() + len) > connector.getMaxPostSize()) { |
| 3152 | // Too much data |
| 3153 | checkSwallowInput(); |
| 3154 | throw new InvalidParameterException(sm.getString("coyoteRequest.chunkedPostTooLarge"), |
| 3155 | HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE); |
| 3156 | } |
| 3157 | if (len > 0) { |
| 3158 | body.append(buffer, 0, len); |
| 3159 | } |
| 3160 | } |
| 3161 | if (body.getLength() == 0) { |
| 3162 | return null; |
| 3163 | } |
| 3164 | if (body.getLength() < body.getBuffer().length) { |
| 3165 | int length = body.getLength(); |
| 3166 | byte[] result = new byte[length]; |
| 3167 | System.arraycopy(body.getBuffer(), 0, result, 0, length); |
| 3168 | return result; |
| 3169 | } |
| 3170 | |
| 3171 | return body.getBuffer(); |
| 3172 | } |
| 3173 | |
| 3174 | |
| 3175 | /** |
no test coverage detected