olegk 2003/03/15 16:09:19 Modified: httpclient/src/java/org/apache/commons/httpclient ConnectMethod.java httpclient/src/java/org/apache/commons/httpclient/methods ExpectContinueMethod.java httpclient/src/test/org/apache/commons/httpclient TestWebappNoncompliant.java Log: Bug #17821 fix http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17821 Changelog: - 'expect: 100-continue' handshake disabled per default, as it may not work properly with older (HTTP/1.0) HTTP servers or proxies (Squid-2.4.STABLE7 for instance) - Wire logging fixed for Connect method Contributed by Oleg Kalnichevski Revision Changes Path 1.9 +17 -6 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ConnectMethod.java Index: ConnectMethod.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ConnectMethod.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ConnectMethod.java 7 Mar 2003 13:50:53 -0000 1.8 +++ ConnectMethod.java 16 Mar 2003 00:09:17 -0000 1.9 @@ -138,13 +138,21 @@ if (method instanceof HttpMethodBase) { ((HttpMethodBase) method).addRequestHeaders(state, conn); } - conn.print(method.getRequestHeader("Host").toExternalForm()); + String line = method.getRequestHeader("Host").toExternalForm(); + conn.print(line); + if (Wire.enabled()) { + Wire.output(line); + } Header header = method.getRequestHeader(Authenticator.PROXY_AUTH_RESP); if (header == null) { header = getRequestHeader(Authenticator.PROXY_AUTH_RESP); } if (header != null) { - conn.print(header.toExternalForm()); + line = header.toExternalForm(); + conn.print(line); + if (Wire.enabled()) { + Wire.output(line); + } } } @@ -165,6 +173,9 @@ String line = getName() + " " + conn.getHost() + ":" + port + " HTTP/1.1"; conn.printLine(line); + if (Wire.enabled()) { + Wire.output(line); + } } /** 1.2 +21 -6 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/ExpectContinueMethod.java Index: ExpectContinueMethod.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/ExpectContinueMethod.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ExpectContinueMethod.java 12 Mar 2003 22:15:13 -0000 1.1 +++ ExpectContinueMethod.java 16 Mar 2003 00:09:18 -0000 1.2 @@ -69,9 +69,17 @@ import org.apache.commons.logging.LogFactory; /** + * <p> * This abstract class serves as a foundation for all HTTP methods - * that support 'Expect: 100-continue' handshake - * + * that support 'Expect: 100-continue' handshake. + * </p> + * + * <p> + * 'Expect: 100-continue' handshake should be used with caution, + * as it may cause problems with HTTP servers and proxies that + * do not support HTTP/1.1 protocol. + * </p> + * * @author <a href="mailto:[EMAIL PROTECTED]">Oleg Kalnichevski</a> * * @since 2.0beta1 @@ -81,7 +89,7 @@ { /** This flag specifies whether "expect: 100-continue" handshake is * to be used prior to sending the request body */ - private boolean useExpectHeader = true; + private boolean useExpectHeader = false; /** LOG object for this class. */ private static final Log LOG = LogFactory.getLog(ExpectContinueMethod.class); @@ -135,6 +143,7 @@ /** * Returns the useExpectHeader. + * * @return boolean * * @since 2.0beta1 @@ -145,8 +154,16 @@ /** * Sets the useExpectHeader. + * + * <p> + * 'Expect: 100-continue' handshake should be used with + * caution, as it may cause problems with HTTP servers and + * proxies that do not support HTTP/1.1 protocol. + * </p> + * * @param value The useExpectHeader to set * + * * @since 2.0beta1 */ public void setUseExpectHeader(boolean value) { @@ -184,10 +201,8 @@ // See if the expect header should be sent // = HTTP/1.1 or higher // = request body present - // = connection is not proxied - if (getUseExpectHeader() && isHttp11() && hasRequestContent() && - !conn.isProxied()) { + if (getUseExpectHeader() && isHttp11() && hasRequestContent()) { if (!headerPresent) { setRequestHeader("Expect", "100-continue"); } 1.4 +1 -0 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestWebappNoncompliant.java Index: TestWebappNoncompliant.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestWebappNoncompliant.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TestWebappNoncompliant.java 5 Mar 2003 04:02:56 -0000 1.3 +++ TestWebappNoncompliant.java 16 Mar 2003 00:09:18 -0000 1.4 @@ -97,6 +97,7 @@ { HttpClient client = createHttpClient(); NoncompliantPostMethod method = new NoncompliantPostMethod("/" + getWebappContext() + "/body"); + method.setUseExpectHeader(true); method.setRequestBody("This is data to be sent in the body of an HTTP POST."); try { client.executeMethod(method);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]