You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Mario Lim (JIRA)" <ji...@apache.org> on 2011/02/03 22:24:28 UTC

[jira] Commented: (HTTPCLIENT-1052) Content-Length not set after setRequestEntity

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12990313#comment-12990313 ] 

Mario Lim commented on HTTPCLIENT-1052:
---------------------------------------

Sorry for the mistake on the release.  I'm actually using the httpcore-4.1.jar not 3.1

> 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: 3.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