Index: java/org/apache/commons/httpclient/ConnectMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ConnectMethod.java,v retrieving revision 1.12 diff -u -r1.12 ConnectMethod.java --- java/org/apache/commons/httpclient/ConnectMethod.java 25 Apr 2003 18:03:28 -0000 1.12 +++ java/org/apache/commons/httpclient/ConnectMethod.java 28 Apr 2003 19:24:18 -0000 @@ -186,6 +186,7 @@ addUserAgentRequestHeader(state, conn); addHostRequestHeader(state, conn); addProxyAuthorizationRequestHeader(state, conn); + addProxyConnectionHeader(state, conn); } /** Index: java/org/apache/commons/httpclient/HttpMethodBase.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v retrieving revision 1.139 diff -u -r1.139 HttpMethodBase.java --- java/org/apache/commons/httpclient/HttpMethodBase.java 27 Apr 2003 19:43:41 -0000 1.139 +++ java/org/apache/commons/httpclient/HttpMethodBase.java 28 Apr 2003 19:25:05 -0000 @@ -1532,6 +1532,27 @@ } /** + * Adds a Proxy-Connection: Keep-Alive request when + * communicating via a proxy server. + * + * @param state current state of http requests + * @param conn the connection to use for I/O + * + * @throws IOException when errors occur reading or writing to/from the + * connection + * @throws HttpException when a recoverable error occurs + */ + protected void addProxyConnectionHeader(HttpState state, + HttpConnection conn) + throws IOException, HttpException { + LOG.trace("enter HttpMethodBase.addProxyConnectionHeader(" + + "HttpState, HttpConnection)"); + if (!conn.isTransparent()) { + setRequestHeader("Proxy-Connection", "Keep-Alive"); + } + } + + /** * Populates the request headers map to with additional {@link Header * headers} to be submitted to the given {@link HttpConnection}. * @@ -1565,6 +1586,7 @@ addCookieRequestHeader(state, conn); addAuthorizationRequestHeader(state, conn); addProxyAuthorizationRequestHeader(state, conn); + addProxyConnectionHeader(state, conn); addContentLengthRequestHeader(state, conn); } @@ -2056,10 +2078,19 @@ //check for a valid HTTP-Version String httpVersion = statusLine.getHttpVersion(); + // TODO: Once a better HTTP protocol versioning scheme is + // introduced, rework the code below + boolean proxied = + statusLine.getStatusCode() == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED; + if (httpVersion.equals("HTTP/1.0")) { - http11 = false; + if (!proxied) { + http11 = false; + } } else if (httpVersion.equals("HTTP/1.1")) { - http11 = true; + if (!proxied) { + http11 = true; + } } else if (httpVersion.equals("HTTP")) { // some servers do not specify the version correctly, we will just assume 1.0 http11 = false;