[ 
https://issues.apache.org/jira/browse/WOOKIE-148?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sander van der Waal updated WOOKIE-148:
---------------------------------------

    Attachment: WOOKIE-148_Proxy_XML.txt

Following the previous comment, these methods in ProxyClient appear to be 
mutually exclusive: 

(98) method.setRequestEntity(new StringRequestEntity(xmlData, "text/xml", 
"UTF8")); 
(99) method.addParameters(this.parameters); 

Since you can post parameters in the body of the original request to the proxy, 
which are (correctly, AFAIK) extracted in the ProxyClient constructor, the 
approach in my patch (attached) is :

                if(this.parameters.length > 0) {
                        method.addParameters(this.parameters);
                } else {
                        method.setRequestEntity(new 
StringRequestEntity(xmlData, "text/xml", "UTF8"));
                }

I'm not happy with the hard-coded content type and content encoding but left it 
in because I considered a refactoring beyond the scope of this patch. 

Just a note therefore, that 'xmlData' is in this case the body of the original 
request so there is no guarantee that it's XML. It's simply the body of the 
original request interpreted as a String (in 
ProxyServlet.getXmlData(HttpServletRequest)). That code uses the default 
charset on the server, therefore there is no guarantee that it's UTF8.




> 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
>         Attachments: WOOKIE-148_Proxy_XML.txt
>
>
> 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