common/src/main/java/HTTPClient/Response.java
/**
     * This reads a set of lines up to and including the first empty line.
     * A line is terminated by either a <CR><LF> or <LF>. The lines are
     * stored in the <var>hdrs</var> buffers. Continued lines are merged
     * and stored as one line.
     *
     * <P>This method is restartable after an InterruptedIOException.
     *
     * @param inp the input stream to read from
     * @exception IOException if any IOException is thrown by the stream
     */
This reads a set of lines up to and including the first empty line.
A line is terminated by either a  or . The lines are
stored in the hdrs buffers. Continued lines are merged
and stored as one line.

This method is restartable after an InterruptedIOException.

@param inp the input stream to read from
@exception IOException if any IOException is thrown by the stream
This reads a set of lines up to and including the first empty line . A line is terminated by either a or . The lines are stored in the hdrs buffers . Continued lines are merged and stored as one line . This method is restartable after an InterruptedIOException . @param inp the input stream to read from @exception IOException if any IOException is thrown by the stream
private void readLines(InputStream inp)  throws IOException
    {
	/* This loop is a merge of readLine() from DataInputStream and
	 * the necessary header logic to merge continued lines and terminate
	 * after an empty line. The reason this is explicit is because of
	 * the need to handle InterruptedIOExceptions.
	 */
	loop: while (true)
	{
	    int b = inp.read();
	    switch (b)
	    {
		case -1:
		    throw new EOFException("Encountered premature EOF while reading headers:\n" + hdrs);
		case '\r':
		    got_cr = true;
		    break;
		case '\n':
		    if (bol)  break loop;	
		    hdrs.append('\n');
		    bol    = true;
		    got_cr = false;
		    break;
		case ' ':
		case '\t':
		    if (bol)		
		    {
			hdrs.setCharAt(hdrs.length()-1, ' ');
			bol = false;
			break;
		    }
		default:
		    if (got_cr)
		    {
			hdrs.append('\r');
			got_cr = false;
		    }
		    hdrs.append((char) (b & 0xFF));
		    bol = false;
		    break;
	    }
	}
    }
private void readLines ( InputStream inp ) throws IOException { /* This loop is a merge of readLine() from DataInputStream and
	 * the necessary header logic to merge continued lines and terminate
	 * after an empty line. The reason this is explicit is because of
	 * the need to handle InterruptedIOExceptions.
	 */ loop : while ( true ) { int b = inp . read ( ) ; switch ( b ) { case - 1 : throw new EOFException ( "Encountered premature EOF while reading headers:\n" + hdrs ) ; case '\r' : got_cr = true ; break ; case '\n' : if ( bol ) break loop ; hdrs . append ( '\n' ) ; bol = true ; got_cr = false ; break ; case ' ' : case '\t' : if ( bol ) { hdrs . setCharAt ( hdrs . length ( ) - 1 , ' ' ) ; bol = false ; break ; } default : if ( got_cr ) { hdrs . append ( '\r' ) ; got_cr = false ; } hdrs . append ( ( char ) ( b & 0xFF ) ) ; bol = false ; break ; } } }
This reads a set of lines up to and including the first empty line.
This reads a set of lines up to and including the first empty line .
// all headers read // a continued line // replace previous \n with SP