common/src/main/java/HTTPClient/Response.java
/**
     * Reads the response headers received, folding continued lines.
     *
     * <P>Some of the code is a bit convoluted because we have to be able
     * restart after an InterruptedIOException.
     *
     * @inp    the input stream from which to read the response
     * @return a (newline separated) list of headers
     * @exception IOException if any read on the input stream fails
     */
Reads the response headers received, folding continued lines.
Some of the code is a bit convoluted because we have to be able
restart after an InterruptedIOException.

@inp    the input stream from which to read the response
@return a (newline separated) list of headers
@exception IOException if any read on the input stream fails
Reads the response headers received folding continued lines . Some of the code is a bit convoluted because we have to be able restart after an InterruptedIOException . @inp the input stream from which to read the response @return a ( newline separated ) list of headers @exception IOException if any read on the input stream fails
private String readResponseHeaders(InputStream inp)  throws IOException
    {
	if (buf_pos == 0)
	    Log.write(Log.RESP, "Resp:  Reading Response headers " +
				inp_stream.hashCode());
	else
	    Log.write(Log.RESP, "Resp:  Resuming reading Response headers " +
				inp_stream.hashCode());
	if (!reading_lines)
	{
	    try
	    {
		if (buf_pos == 0)
		{
		    int c;
		    do
		    {
			if ((c = inp.read()) == -1)
			    throw new EOFException("Encountered premature EOF "
						   + "while reading Version");
		    } while (Character.isWhitespace((char) c)) ;
		    buf[0] = (byte) c;
		    buf_pos = 1;
		}
		while (buf_pos < buf.length)
		{
		    int got = inp.read(buf, buf_pos, buf.length-buf_pos);
		    if (got == -1)
			throw new EOFException("Encountered premature EOF " +
						"while reading Version");
		    buf_pos += got;
		}
	    }
	    catch (EOFException eof)
	    {
		Log.write(Log.RESP, "Resp:  (" + inp_stream.hashCode() + ")",
			  eof);
		throw eof;
	    }
	    for (int idx=0; idx<buf.length; idx++)
		hdrs.append((char) buf[idx]);
	    reading_lines = true;
	}
	if (hdrs.toString().startsWith("HTTP/")  ||		
	    hdrs.toString().startsWith("HTTP "))		
	    readLines(inp);
	buf_pos = 0;
	reading_lines = false;
	bol     = true;
	got_cr  = false;
	String tmp = hdrs.toString();
	hdrs.setLength(0);
	return tmp;
    }
private String readResponseHeaders ( InputStream inp ) throws IOException { if ( buf_pos == 0 ) Log . write ( Log . RESP , "Resp:  Reading Response headers " + inp_stream . hashCode ( ) ) ; else Log . write ( Log . RESP , "Resp:  Resuming reading Response headers " + inp_stream . hashCode ( ) ) ; if ( ! reading_lines ) { try { if ( buf_pos == 0 ) { int c ; do { if ( ( c = inp . read ( ) ) == - 1 ) throw new EOFException ( "Encountered premature EOF " + "while reading Version" ) ; } while ( Character . isWhitespace ( ( char ) c ) ) ; buf [ 0 ] = ( byte ) c ; buf_pos = 1 ; } while ( buf_pos < buf . length ) { int got = inp . read ( buf , buf_pos , buf . length - buf_pos ) ; if ( got == - 1 ) throw new EOFException ( "Encountered premature EOF " + "while reading Version" ) ; buf_pos += got ; } } catch ( EOFException eof ) { Log . write ( Log . RESP , "Resp:  (" + inp_stream . hashCode ( ) + ")" , eof ) ; throw eof ; } for ( int idx = 0 ; idx < buf . length ; idx ++ ) hdrs . append ( ( char ) buf [ idx ] ) ; reading_lines = true ; } if ( hdrs . toString ( ) . startsWith ( "HTTP/" ) || hdrs . toString ( ) . startsWith ( "HTTP " ) ) readLines ( inp ) ; buf_pos = 0 ; reading_lines = false ; bol = true ; got_cr = false ; String tmp = hdrs . toString ( ) ; hdrs . setLength ( 0 ) ; return tmp ; }
Reads the response headers received, folding continued lines.
Reads the response headers received folding continued lines .
// read 7 bytes to see type of response // Skip any leading white space to accomodate buggy responses // Now read first seven bytes (the version string) // It's x.x // NCSA bug // reset variables for next round