You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by "Sander van der Waal (JIRA)" <ji...@apache.org> on 2010/07/23 16:26:50 UTC
[jira] Created: (WOOKIE-148) Posting XML in the body of a text/xml
HTTP request through the proxy fails
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.
[jira] Commented: (WOOKIE-148) Posting XML in the body of a
text/xml HTTP request through the proxy fails
Posted by "Sander van der Waal (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Updated: (WOOKIE-148) Posting XML in the body of a text/xml
HTTP request through the proxy fails
Posted by "Scott Wilson (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WOOKIE-148?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Scott Wilson updated WOOKIE-148:
--------------------------------
Fix Version/s: 0.9.0
> 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
> Fix For: 0.9.0
>
> 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.
[jira] Updated: (WOOKIE-148) Posting XML in the body of a text/xml
HTTP request through the proxy fails
Posted by "Sander van der Waal (JIRA)" <ji...@apache.org>.
[ 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.