Return-Path: Delivered-To: apmail-jakarta-httpclient-dev-archive@www.apache.org Received: (qmail 93732 invoked from network); 15 Sep 2006 13:13:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Sep 2006 13:13:19 -0000 Received: (qmail 49061 invoked by uid 500); 15 Sep 2006 13:13:18 -0000 Delivered-To: apmail-jakarta-httpclient-dev-archive@jakarta.apache.org Received: (qmail 49035 invoked by uid 500); 15 Sep 2006 13:13:18 -0000 Mailing-List: contact httpclient-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "HttpClient Project" Reply-To: "HttpClient Project" Delivered-To: mailing list httpclient-dev@jakarta.apache.org Received: (qmail 49024 invoked by uid 99); 15 Sep 2006 13:13:18 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Sep 2006 06:13:18 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Sep 2006 06:13:15 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id C846B714346 for ; Fri, 15 Sep 2006 13:09:22 +0000 (GMT) Message-ID: <11985442.1158325762801.JavaMail.jira@brutus> Date: Fri, 15 Sep 2006 06:09:22 -0700 (PDT) From: "Roland Weber (JIRA)" To: httpclient-dev@jakarta.apache.org Subject: [jira] Commented: (HTTPCLIENT-600) Http Client does not fix incorrect content-lenght headers In-Reply-To: <25271473.1158316522269.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/HTTPCLIENT-600?page=comments#action_12434962 ] Roland Weber commented on HTTPCLIENT-600: ----------------------------------------- Hi Denis, HttpClient behaves exactly as intended. If there is no Content-Length header, HttpClient tries to compute one. If you think you know better what the Content-Length header should be, and set it explicitly, then you do so on your own risk and responsibility. HttpClient will not modify headers that were set explicitly. That's mainly because somebody might have to create requests that are actually invalid, but are similar to what some other, broken HTTP application generates. If you want HttpClient to provide the content length, then just don't set it. If you want to verify the value you set, then use RequestEntity.getContentLength() in your application. Reverse proxies are supposed to know which headers can be sent on and which can not. A proxy that modifies the request entity is also responsible for updating all entity headers that might be affected by that change. Please open an issue against the reverse proxy program that misbehaves. I suggest to mark this issue invalid. cheers, Roland > Http Client does not fix incorrect content-lenght headers > --------------------------------------------------------- > > Key: HTTPCLIENT-600 > URL: http://issues.apache.org/jira/browse/HTTPCLIENT-600 > Project: HttpComponents HttpClient > Issue Type: Improvement > Components: HttpClient > Affects Versions: 3.1 Alpha 1 > Environment: All > Reporter: Denis Valdenaire > > I discovered that the method > addContentLengthRequestHeader (found in file methods/MultipartPostMethod.java) doesn't "fix" the content-lenght when this one is incorrect. It adds one if getRequestHeader("Content-Lenght") is null, but it should also verify that the content-lenght is correct. > I suggest something like : > long len = getRequestContentLength(); > if (getRequestHeader("Content-Length") == null || getRequestHeader("Content-Length") != len) { > setRequestHeader("Content-Length", String.valueOf(len)); > } > Sending an incorrect Content-Length blocks the server if the string sent is smaller than announced : waiting for more, and finally reset the connection. If it's too big, you lose data. > I've seen this problem in a reverse proxy program (with httpclient communicating with the real servers) when the client send urlencoded data and this data is modified (partly urldecoded) but not the content-lenght. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org