common/src/main/java/HTTPClient/StreamDemultiplexor.java
/**
     * Mark this demux to not accept any more request and to close the
     * stream after this <var>resp</var>onse or all requests have been
     * processed, or close immediately if no requests are registered.
     *
     * @param response the Response after which the connection should
     *                 be closed.
     */
Mark this demux to not accept any more request and to close the
stream after this response or all requests have been
processed, or close immediately if no requests are registered.

@param response the Response after which the connection should
be closed.
Mark this demux to not accept any more request and to close the stream after this response or all requests have been processed or close immediately if no requests are registered . @param response the Response after which the connection should be closed .
synchronized void markForClose(Response resp)
    {
	synchronized (RespHandlerList)
	{
	    if (RespHandlerList.getFirst() == null)	
	    {						
		close(new IOException("Premature end of Keep-Alive"), false);
		return;
	    }
	    if (Timer != null)
	    {
		Timer.kill();
		Timer = null;
	    }
	    ResponseHandler resph, lasth = null;
	    for (resph = (ResponseHandler) RespHandlerList.enumerate();
		 resph != null;
		 resph = (ResponseHandler) RespHandlerList.next())
	    {
		if (resph.resp == resp)	
		{
		    MarkedForClose = resph;
		    Log.write(Log.DEMUX, "Demux: stream " +
					 resp.inp_stream.hashCode() +
					 " marked for close");
		    closeSocketIfAllStreamsClosed();
		    return;
		}
		if (MarkedForClose == resph)
		    return;	
		lasth = resph;
	    }
	    if (lasth == null)
		return;
	    MarkedForClose = lasth;		
	    closeSocketIfAllStreamsClosed();
	    Log.write(Log.DEMUX, "Demux: stream " + lasth.stream.hashCode() +
				 " marked for close");
	}
    }
synchronized void markForClose ( Response resp ) { synchronized ( RespHandlerList ) { if ( RespHandlerList . getFirst ( ) == null ) { close ( new IOException ( "Premature end of Keep-Alive" ) , false ) ; return ; } if ( Timer != null ) { Timer . kill ( ) ; Timer = null ; } ResponseHandler resph , lasth = null ; for ( resph = ( ResponseHandler ) RespHandlerList . enumerate ( ) ; resph != null ; resph = ( ResponseHandler ) RespHandlerList . next ( ) ) { if ( resph . resp == resp ) { MarkedForClose = resph ; Log . write ( Log . DEMUX , "Demux: stream " + resp . inp_stream . hashCode ( ) + " marked for close" ) ; closeSocketIfAllStreamsClosed ( ) ; return ; } if ( MarkedForClose == resph ) return ; lasth = resph ; } if ( lasth == null ) return ; MarkedForClose = lasth ; closeSocketIfAllStreamsClosed ( ) ; Log . write ( Log . DEMUX , "Demux: stream " + lasth . stream . hashCode ( ) + " marked for close" ) ; } }
Mark this demux to not accept any more request and to close the
 stream after this <var>resp</var>onse or all requests have been
 processed, or close immediately if no requests are registered.
Mark this demux to not accept any more request and to close the stream after this <var > resp< / var > onse or all requests have been processed or close immediately if no requests are registered .
// no active request, // so close the socket // new resp precedes any others // already marked for closing after an earlier resp // resp == null, so use last resph