common/src/main/java/HTTPClient/RespInputStream.java
/**
     * Reads all remainings data into buffer. This is used to force a read
     * of upstream responses.
     *
     * <P>This is probably the most tricky and buggy method around. It's the
     * only one that really violates the strict top-down method invocation
     * from the Response through the ResponseStream to the StreamDemultiplexor.
     * This means we need to be awfully careful about what is synchronized
     * and what parameters are passed to whom.
     *
     * @param timeout the timeout to use for reading from the demux
     * @exception IOException If any exception occurs while reading stream.
     */
Reads all remainings data into buffer. This is used to force a read
of upstream responses.

This is probably the most tricky and buggy method around. It's the
only one that really violates the strict top-down method invocation
from the Response through the ResponseStream to the StreamDemultiplexor.
This means we need to be awfully careful about what is synchronized
and what parameters are passed to whom.

@param timeout the timeout to use for reading from the demux
@exception IOException If any exception occurs while reading stream.
Reads all remainings data into buffer . This is used to force a read of upstream responses . This is probably the most tricky and buggy method around . It ' s the only one that really violates the strict top - down method invocation from the Response through the ResponseStream to the StreamDemultiplexor . This means we need to be awfully careful about what is synchronized and what parameters are passed to whom . @param timeout the timeout to use for reading from the demux @exception IOException If any exception occurs while reading stream .
void readAll(int timeout)  throws IOException
    {
	Log.write(Log.DEMUX, "RspIS: Read-all on stream " + this.hashCode());
	synchronized (resph.resp)
	{
	    if (!resph.resp.got_headers)	
	    {
		int sav_to = resph.resp.timeout;
		resph.resp.timeout = timeout;
		resph.resp.getStatusCode();
		resph.resp.timeout = sav_to;
	    }
	}
	synchronized (this)
	{
	    if (buffer != null  &&  !interrupted)  return;
	    int rcvd = 0;
	    try
	    {
		if (closed)			
		{
		    buffer = new byte[10000];
		    do
		    {
			count += rcvd;
			rcvd   = demux.read(buffer, 0, buffer.length, resph,
					    timeout);
		    } while (rcvd != -1);
		    buffer = null;
		}
		else
		{
		    if (buffer == null)
		    {
			buffer = new byte[10000];
			offset = 0;
			end    = 0;
		    }
		    do
		    {
			rcvd = demux.read(buffer, end, buffer.length-end, resph,
					  timeout);
			if (rcvd < 0)  break;
			count  += rcvd;
			end    += rcvd;
			buffer  = Util.resizeArray(buffer, end+10000);
		    } while (true);
		}
	    }
	    catch (InterruptedIOException iioe)
	    {
		interrupted = true;
		throw iioe;
	    }
	    catch (IOException ioe)
	    {
		buffer = null;	
	    }
	    interrupted = false;
	}
    }
void readAll ( int timeout ) throws IOException { Log . write ( Log . DEMUX , "RspIS: Read-all on stream " + this . hashCode ( ) ) ; synchronized ( resph . resp ) { if ( ! resph . resp . got_headers ) { int sav_to = resph . resp . timeout ; resph . resp . timeout = timeout ; resph . resp . getStatusCode ( ) ; resph . resp . timeout = sav_to ; } } synchronized ( this ) { if ( buffer != null && ! interrupted ) return ; int rcvd = 0 ; try { if ( closed ) { buffer = new byte [ 10000 ] ; do { count += rcvd ; rcvd = demux . read ( buffer , 0 , buffer . length , resph , timeout ) ; } while ( rcvd != - 1 ) ; buffer = null ; } else { if ( buffer == null ) { buffer = new byte [ 10000 ] ; offset = 0 ; end = 0 ; } do { rcvd = demux . read ( buffer , end , buffer . length - end , resph , timeout ) ; if ( rcvd < 0 ) break ; count += rcvd ; end += rcvd ; buffer = Util . resizeArray ( buffer , end + 10000 ) ; } while ( true ) ; } } catch ( InterruptedIOException iioe ) { interrupted = true ; throw iioe ; } catch ( IOException ioe ) { buffer = null ; } interrupted = false ; } }
Reads all remainings data into buffer.
Reads all remainings data into buffer .
// force headers to be read // throw away // force a read on demux for exception