• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.0.1.79
ChunkedInputStream Class Reference

Implements chunked transfer coding. More...

Inheritance diagram for ChunkedInputStream:
InputStream

Description

See RFC 2616, section 3.6.1. It transparently coalesces chunks of a HTTP stream that uses chunked transfer coding. After the stream is read to the end, it provides access to the trailers, if any.

Note that this class NEVER closes the underlying stream, even when close gets called. Instead, it will read until the "end" of its chunking on close, which allows for the seamless execution of subsequent HTTP 1.1 requests, while not requiring the client to remember to read the entire contents of the response.

Author
Ortwin Glueck
Sean C. Sullivan
Martin Elwin
Eric Johnson
Mike Bowler
Michael Becke
Oleg Kalnichevski
Since
4.0

Notice

The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.

/*
 * Copyright (C) 2006 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Public Member Functions

int read () throws IOException
 
int read (byte[] b, int off, int len) throws IOException
 Read some bytes from the stream. More...
 
int read (byte[] b) throws IOException
 Read some bytes from the stream. More...
 
void close () throws IOException
 Upon close, this reads the remainder of the chunked message, leaving the underlying socket at a position to start reading the next response without scanning. More...
 

Member Function Documentation

◆ read() [1/3]

int read ( ) throws IOException

Returns all the data in a chunked stream in coalesced form. A chunk is followed by a CRLF. The method returns -1 as soon as a chunksize of 0 is detected.

Trailer headers are read automcatically at the end of the stream and can be obtained with the getResponseFooters() method.

Returns
-1 of the end of the stream has been reached or the next data byte
Exceptions
IOExceptionIf an IO problem occurs

◆ read() [2/3]

int read ( byte[]  b,
int  off,
int  len 
) throws IOException
Parameters
bThe byte array that will hold the contents from the stream.
offThe offset into the byte array at which bytes will start to be placed.
lenthe maximum number of bytes that can be returned.
Returns
The number of bytes returned or -1 if the end of stream has been reached.
See also
java.io.InputStream::read(byte[], int, int)
Exceptions
IOExceptionif an IO problem occurs.

◆ read() [3/3]

int read ( byte[]  b) throws IOException
Parameters
bThe byte array that will hold the contents from the stream.
Returns
The number of bytes returned or -1 if the end of stream has been reached.
See also
java.io.InputStream::read(byte[])
Exceptions
IOExceptionif an IO problem occurs.

◆ close()

void close ( ) throws IOException
Exceptions
IOExceptionIf an IO problem occurs.