src/HTTPClient/HTTPConnection.java
/**
     * The very first request is special in that we use it to figure out the
     * protocol version the server (or proxy) is compliant with.
     *
     * @return true if all went fine, false if the request needs to be resent
     * @exception IOException if any exception is thrown by the response
     */
The very first request is special in that we use it to figure out the
protocol version the server (or proxy) is compliant with.

@return true if all went fine, false if the request needs to be resent
@exception IOException if any exception is thrown by the response
The very first request is special in that we use it to figure out the protocol version the server ( or proxy ) is compliant with . @return true if all went fine false if the request needs to be resent @exception IOException if any exception is thrown by the response
boolean handleFirstRequest(Request req, Response resp)  throws IOException
    {
	ServerProtocolVersion = String2ProtVers(resp.getVersion());
	ServProtVersKnown = true;
	/* We need to treat connections through proxies specially, because
	 * many HTTP/1.0 proxies do not downgrade an HTTP/1.1 response
	 * version to HTTP/1.0 (i.e. when we are talking to an HTTP/1.1
	 * server through an HTTP/1.0 proxy we are mislead to thinking we're
	 * talking to an HTTP/1.1 proxy). We use the absence of the Via
	 * header to detect whether we're talking to an HTTP/1.0 proxy,
	 * unless the status code indicates an error from the proxy
	 * itself. However, this only works when the chain contains
	 * only HTTP/1.0 proxies; if you have <client - 1.0 proxy - 1.1
	 * proxy - server> then this will fail too. Unfortunately there
	 * seems to be no way to reliably detect broken HTTP/1.0
	 * proxies...
	 */
	int sts = resp.getStatusCode();
	if ((Proxy_Host != null  &&  Protocol != HTTPS)  &&
	    resp.getHeader("Via") == null  &&
	    sts != 407  &&  sts != 502  &&  sts != 504)
	    ServerProtocolVersion = HTTP_1_0;
	Log.write(Log.CONN, "Conn:  Protocol Version established: " +
			    ProtVers2String(ServerProtocolVersion));
	if (ServerProtocolVersion == HTTP_1_0  &&
	    (resp.getStatusCode() == 400  ||  resp.getStatusCode() == 500))
	{
	    if (input_demux != null)
		input_demux.markForClose(resp);
	    input_demux = null;
	    RequestProtocolVersion = "HTTP/1.0";
	    return false;
	}
	return true;
    }
boolean handleFirstRequest ( Request req , Response resp ) throws IOException { ServerProtocolVersion = String2ProtVers ( resp . getVersion ( ) ) ; ServProtVersKnown = true ; /* We need to treat connections through proxies specially, because
	 * many HTTP/1.0 proxies do not downgrade an HTTP/1.1 response
	 * version to HTTP/1.0 (i.e. when we are talking to an HTTP/1.1
	 * server through an HTTP/1.0 proxy we are mislead to thinking we're
	 * talking to an HTTP/1.1 proxy). We use the absence of the Via
	 * header to detect whether we're talking to an HTTP/1.0 proxy,
	 * unless the status code indicates an error from the proxy
	 * itself. However, this only works when the chain contains
	 * only HTTP/1.0 proxies; if you have <client - 1.0 proxy - 1.1
	 * proxy - server> then this will fail too. Unfortunately there
	 * seems to be no way to reliably detect broken HTTP/1.0
	 * proxies...
	 */ int sts = resp . getStatusCode ( ) ; if ( ( Proxy_Host != null && Protocol != HTTPS ) && resp . getHeader ( "Via" ) == null && sts != 407 && sts != 502 && sts != 504 ) ServerProtocolVersion = HTTP_1_0 ; Log . write ( Log . CONN , "Conn:  Protocol Version established: " + ProtVers2String ( ServerProtocolVersion ) ) ; if ( ServerProtocolVersion == HTTP_1_0 && ( resp . getStatusCode ( ) == 400 || resp . getStatusCode ( ) == 500 ) ) { if ( input_demux != null ) input_demux . markForClose ( resp ) ; input_demux = null ; RequestProtocolVersion = "HTTP/1.0" ; return false ; } return true ; }
The very first request is special in that we use it to figure out the
 protocol version the server (or proxy) is compliant with.
The very first request is special in that we use it to figure out the protocol version the server ( or proxy ) is compliant with .
// read response headers to get protocol version used by // the server. // some (buggy) servers return an error status if they get a // version they don't comprehend