Folks, Here's the patch to tone down warning messages generated by the readResponseBody method when encountering non-fatal protocol violations. All changes are mostly cosmetical, so I'll apply the patch tonight (~ 21:00GMT) if I hear no loud complaints by then
Oleg PS: the patch is against 2.0 branch 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.159.2.30 diff -u -r1.159.2.30 HttpMethodBase.java --- java/org/apache/commons/httpclient/HttpMethodBase.java 27 Jul 2004 01:34:48 -0000 1.159.2.30 +++ java/org/apache/commons/httpclient/HttpMethodBase.java 19 Aug 2004 08:25:43 -0000 @@ -2008,9 +2008,9 @@ private InputStream readResponseBody(HttpConnection conn) throws IOException { - LOG.trace("enter HttpMethodBase.readResponseBody(HttpState, HttpConnection)"); + LOG.trace("enter HttpMethodBase.readResponseBody(HttpConnection)"); - responseBody = null; // is this desired? + responseBody = null; InputStream is = conn.getResponseInputStream(); if (Wire.CONTENT_WIRE.enabled()) { is = new WireLogInputStream(is, Wire.CONTENT_WIRE); @@ -2044,10 +2044,7 @@ } } } else { - if (LOG.isWarnEnabled()) { - LOG.warn("Transfer-Encoding is set but does not contain \"chunked\": " - + transferEncoding); - } + LOG.info("Response content is not chunk-encoded"); // The connection must be terminated by closing // the socket as per RFC 2616, 3.6 setConnectionCloseForced(true); @@ -2062,8 +2059,8 @@ if (connectionHeader != null) { connectionDirective = connectionHeader.getValue(); } - if (!"close".equalsIgnoreCase(connectionDirective)) { - LOG.warn("Response content length is not known"); + if (isHttp11() && !"close".equalsIgnoreCase(connectionDirective)) { + LOG.info("Response content length is not known"); setConnectionCloseForced(true); } result = is; -----Original Message----- From: Kalnichevski, Oleg Sent: Wednesday, August 18, 2004 12:14 PM To: Commons HttpClient Project Subject: RE: Response content length is not known > Otherwise, dynamically generated content would have been a major problem > with HTTP/1.0, or so I figure. Actually it has been as a problem. That is primarily why HTTP/1.1 had to introduce the generic 'transfer-encoding' mechanism and the chunk encoding as its default implementation. Anyways, you are right. HTTP/1.0 responses that include an entity body may ommit the 'content-lenght' header. I'll provide a patch to disable the warning for HTTP/1.0 responses Oleg -----Original Message----- From: Roland Weber [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 18, 2004 11:46 AM To: Commons HttpClient Project Subject: RE: Response content length is not known Hi Oleg, "Kalnichevski, Oleg" <[EMAIL PROTECTED]> wrote on 18.08.2004 11:26:10: > << "HTTP/1.0 200 OK[\r][\n]" > << "Date: Thu, 19 Aug 2004 02:01:34 GMT[\r][\n]" > << "Server: Oracle9iAS (9.0.3.0.0) Containers for J2EE[\r][\n]" > << "Content-Type: text/html[\r][\n]" > > As you can see the response does not contain a 'content-length' > header which is mandatory for the 200 (OK) response, hence the warning > > <RFC1945> > > 7.2 Entity Body > > ... > > For response messages, ... [a]ll 1xx (informational), 204 (no > content), and 304 (not modified) responses must not include a body. > All other responses must include an entity body or a Content-Length > header field defined with a value of zero (0). > > > </RFC1945> It says "or". Meaning if there is a body, there is no need for the Content-Length header, right? It's mandatory only with value 0, to indicate that there is no body. Otherwise, dynamically generated content would have been a major problem with HTTP/1.0, or so I figure. But I'm not familiar with RFC 1945, so please correct me if I'm wrong. cheers, Roland *************************************************************************************************** The information in this email is confidential and may be legally privileged. Access to this email by anyone other than the intended addressee is unauthorized. If you are not the intended recipient of this message, any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful. If you are not the intended recipient, please reply to or forward a copy of this message to the sender and delete the message, any attachments, and any copies thereof from your system. *************************************************************************************************** --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] *************************************************************************************************** The information in this email is confidential and may be legally privileged. Access to this email by anyone other than the intended addressee is unauthorized. If you are not the intended recipient of this message, any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful. If you are not the intended recipient, please reply to or forward a copy of this message to the sender and delete the message, any attachments, and any copies thereof from your system. *************************************************************************************************** --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]