[ 
https://issues.apache.org/jira/browse/WOOKIE-148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12891626#action_12891626
 ] 

Sander van der Waal commented on WOOKIE-148:
--------------------------------------------

According to the commons-httpclient-3.x JavaDoc [2]:

 void   addParameters(NameValuePair[] parameters) 
          Adds an array of parameters to be used in the POST request body.


So the parameters that are set in the body of the request, which explains why 
the request body is cleared out and my XML data is lost. 

In my example there are no parameters so this can be skipped, but I can't 
oversee other use cases. 

I'll test further and submit my solution as a patch.

[2] 
http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/methods/PostMethod.html

> Posting XML in the body of a text/xml HTTP request through the proxy fails
> --------------------------------------------------------------------------
>
>                 Key: WOOKIE-148
>                 URL: https://issues.apache.org/jira/browse/WOOKIE-148
>             Project: Wookie
>          Issue Type: Bug
>          Components: Server
>         Environment: Working on the trunk (rev.956738) on Windows XP
>            Reporter: Sander van der Waal
>
> When I post an XML document through the proxy the content is truncated by the 
> ProxyClient which results in an empty body in the HTTP request from the proxy 
> to the URL I want to post to.
> Specifically, in JavaScript I construct something similar to this [1]:
>   var xml_data = "<xml>some xml</xml>";
>   var xml_request = new XMLHttpRequest();
>   var loc = 'http://localhost:8080/simal-rest/addProject';
>   loc = Widget.proxify(loc);
>   xml_request.open("POST", loc, true);
>   xml_request.setRequestHeader("Cache-Control", "no-cache");
>   xml_request.setRequestHeader("Content-Type", "text/xml");
>   xml_request.send(xml_data);
> Everything's fine until the post mehod in ProxyClient, which does (lines 
> 96-100): 
> (96)  PostMethod method = new PostMethod(uri);
> (97)  method.setDoAuthentication(true);
> (98)  method.setRequestEntity(new StringRequestEntity(xmlData, "text/xml", 
> "UTF8"));
> (99)  method.addParameters(this.parameters); 
> (100)  return executeMethod(method, properties);
> After (98) the requestEntity is set in the PostMethod, but directly after 
> (99) it's back to null again, and as a result the HTTP request that is sent 
> contains an empty body.
> [1] 
> https://simal.googlecode.com/svn/trunk/uk.ac.osswatch.simal.web/src/main/widgets/doapcreator/scripts/doapform.js
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to