common/src/main/java/HTTPClient/StreamDemultiplexor.java
/**
     * Determines the number of available bytes. If <var>resph</var> is null, return
     * available bytes on the socket stream itself (used by HTTPConnection).
     */
Determines the number of available bytes. If resph is null, return
available bytes on the socket stream itself (used by HTTPConnection).
Determines the number of available bytes . If resph is null return available bytes on the socket stream itself ( used by HTTPConnection ) .
synchronized int available(ResponseHandler resph) throws IOException
    {
	if (resph != null  &&  resph.exception != null)
	{
	    resph.exception.fillInStackTrace();
	    throw resph.exception;
	}
	if (resph != null  &&  resph.eof)
	    return 0;
	int avail = Stream.available();
	if (resph == null)
	  return avail;
	switch (resph.resp.cd_type)
	{
	    case CD_0:
		return 0;
	    case CD_HDRS:
		return (avail > 0 ? 1 : 0);
	    case CD_CLOSE:
		return avail;
	    case CD_CONTLEN:
		int cl = resph.resp.ContentLength;
		cl -= resph.stream.count;
		return (avail < cl ? avail : cl);
	    case CD_CHUNKED:
		return avail;	
	    case CD_MP_BR:
		return avail;	
	    default:
		throw new Error("Internal Error in StreamDemultiplexor: " +
				"Invalid cd_type " + resph.resp.cd_type);
	}
    }
synchronized int available ( ResponseHandler resph ) throws IOException { if ( resph != null && resph . exception != null ) { resph . exception . fillInStackTrace ( ) ; throw resph . exception ; } if ( resph != null && resph . eof ) return 0 ; int avail = Stream . available ( ) ; if ( resph == null ) return avail ; switch ( resph . resp . cd_type ) { case CD_0 : return 0 ; case CD_HDRS : return ( avail > 0 ? 1 : 0 ) ; case CD_CLOSE : return avail ; case CD_CONTLEN : int cl = resph . resp . ContentLength ; cl -= resph . stream . count ; return ( avail < cl ? avail : cl ) ; case CD_CHUNKED : return avail ; case CD_MP_BR : return avail ; default : throw new Error ( "Internal Error in StreamDemultiplexor: " + "Invalid cd_type " + resph . resp . cd_type ) ; } }
Determines the number of available bytes.
Determines the number of available bytes .
// this is something of a hack; I could return 0, but then // if you were waiting for something on a response that // wasn't first in line (and you didn't try to read the // other response) you'd wait forever. On the other hand, // we might be making a false promise here... // not perfect... // not perfect...