org.apache.http.ContentTooLongException Java Examples

The following examples show how to use org.apache.http.ContentTooLongException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractResponseConsumer.java    From fc-java-sdk with MIT License 5 votes vote down vote up
protected void onEntityEnclosed(HttpEntity entity, ContentType contentType) throws IOException {
    long len = entity.getContentLength();
    if (len > 2147483647L) {
        throw new ContentTooLongException("Entity content is too long: " + len);
    } else {
        if (len < 0L) {
            len = 4096L;
        }

        this.buf = new SimpleInputBuffer((int)len, new HeapByteBufferAllocator());
        this.httpResponse.setEntity(new ContentBufferEntity(entity, this.buf));
    }
}
 
Example #2
Source File: HttpEntityWrapper.java    From yunpian-java-sdk with MIT License 5 votes vote down vote up
@Override
public InputStream getContent() throws IOException {
    if (this.getContentLength() < 0) { throw new ContentTooLongException("Content length is unknown"); }
    // else if (this.contentLength > 25 * 1024) {
    // throw new ContentTooLongException("Content length is too long: " + this.contentLength);
    // }
    final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
    writeTo(outstream);
    outstream.flush();
    return new ByteArrayInputStream(outstream.toByteArray());
}
 
Example #3
Source File: ResponseConsumer.java    From aliyun-tablestore-java-sdk with Apache License 2.0 5 votes vote down vote up
@Override
protected void onEntityEnclosed(final HttpEntity entity,
        final ContentType contentType) throws IOException {
    long len = entity.getContentLength();
    if (len > Integer.MAX_VALUE) {
        throw new ContentTooLongException("Entity content is too long: "
                + len);
    }
    if (len < 0) {
        len = BUFFER_SIZE;
    }
    this.buf = new SimpleInputBuffer((int) len,
            new HeapByteBufferAllocator());
    this.httpResponse.setEntity(new ContentBufferEntity(entity, this.buf));
}