hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mario Lim (JIRA)" <j...@apache.org>
Subject [jira] Created: (HTTPCLIENT-1052) Content-Length not set after setRequestEntity
Date Thu, 03 Feb 2011 17:17:29 GMT
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


Mime
View raw message