org.apache.commons.httpclient.ChunkedInputStream Java Examples

The following examples show how to use org.apache.commons.httpclient.ChunkedInputStream. 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: KcaUtils.java    From kcanotify_h5-master with GNU General Public License v3.0 6 votes vote down vote up
public static byte[] unchunkdata(byte[] contentBytes) throws IOException {
    byte[] unchunkedData = null;
    byte[] buffer = new byte[1024];
    ByteArrayInputStream bis = new ByteArrayInputStream(contentBytes);
    ChunkedInputStream cis = new ChunkedInputStream(bis);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();

    int read = -1;
    while ((read = cis.read(buffer)) != -1) {
        bos.write(buffer, 0, read);
    }
    unchunkedData = bos.toByteArray();
    bos.close();

    return unchunkedData;
}
 
Example #2
Source File: KcaUtils.java    From kcanotify with GNU General Public License v3.0 6 votes vote down vote up
public static byte[] unchunkdata(byte[] contentBytes) throws IOException {
    byte[] unchunkedData = null;
    byte[] buffer = new byte[1024];
    ByteArrayInputStream bis = new ByteArrayInputStream(contentBytes);
    ChunkedInputStream cis = new ChunkedInputStream(bis);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();

    int read = -1;
    while ((read = cis.read(buffer)) != -1) {
        bos.write(buffer, 0, read);
    }
    unchunkedData = bos.toByteArray();
    bos.close();

    return unchunkedData;
}
 
Example #3
Source File: Recorder.java    From webarchive-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Get a raw replay of the 'entity'. For the common case of 
 * HTTP, this is the message-body after any (usually-unnecessary)
 * transfer-decoding but before any content-encoding (eg gzip) decoding
 * 
 * @return A replay input stream.
 * @throws IOException
 */
public InputStream getEntityReplayInputStream() throws IOException {
    if(inputIsChunked) {
        return new ChunkedInputStream(getRecordedInput().getMessageBodyReplayInputStream());
    } else {
        return getRecordedInput().getMessageBodyReplayInputStream();
    }
}