Return-Path: Delivered-To: apmail-hc-dev-archive@www.apache.org Received: (qmail 4266 invoked from network); 3 Feb 2011 21:26:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Feb 2011 21:26:53 -0000 Received: (qmail 36948 invoked by uid 500); 3 Feb 2011 21:26:53 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 36910 invoked by uid 500); 3 Feb 2011 21:26:52 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 36889 invoked by uid 99); 3 Feb 2011 21:26:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Feb 2011 21:26:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Feb 2011 21:26:49 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 0065B18C1FC for ; Thu, 3 Feb 2011 21:26:29 +0000 (UTC) Date: Thu, 3 Feb 2011 21:26:28 +0000 (UTC) From: "Mario Lim (JIRA)" To: dev@hc.apache.org Message-ID: <1858857037.8479.1296768388998.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1867756813.7703.1296753449030.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] Updated: (HTTPCLIENT-1052) Content-Length not set after setRequestEntity MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HTTPCLIENT-1052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Mario Lim updated HTTPCLIENT-1052: ---------------------------------- Affects Version/s: (was: 3.1 Final) 4.1 Final > Content-Length not set after setRequestEntity > --------------------------------------------- > > Key: HTTPCLIENT-1052 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1052 > Project: HttpComponents HttpClient > Issue Type: Bug > Components: HttpClient > Affects Versions: 4.1 Final > Environment: Windows > Reporter: Mario Lim > Priority: Minor > > I'm using setRequestEntity in a loop where the PutMethod is define outside the loop. Content-length should be set by setRequestEntity everytime. However, it seems to remember that last conten-length. I had to call the removeRequestHeader("content-length") at the end of the loop so that it would be set correctly the next time setRequestEntity is called. > Here is the sample of what I'm doing: > PutMethod put = new PutMethod("http://localhost:8888/entity/0"); > Header accept = new Header(); > accept.setName("Accept"); > accept.setValue("application/json"); > put.addRequestHeader(accept); > RequestEntity entity = null; > for (int i = 0; i < 100; i++) { > entity = new StringRequestEntity("someEntity" + i, "application/json", "UTF-8"); > put.setRequestEntity(entity); > HttpClient httpclient = new HttpClient(); > int result = httpclient.executeMethod(put); > // It seems there is a bug in setRequestEntity where it won't replace the previous > // content-length. This causes the server to not receive the right length after the 10th iteration > put.removeRequestHeader("content-length"); > } -- This message is automatically generated by JIRA. - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org