Keep URL encoded while rewriting

49 views
Skip to first unread message

victo...@gmail.com

unread,
Mar 27, 2015, 11:50:18 AM3/27/15
to membrane...@googlegroups.com
Hi,

I'm using the source downloaded from 4.0.20 versioned zip, and found the <rewriter> tag somehow doesn't preserve the original URL encoding after rewriting. e.g. the original "/bank/view?a=x%20y" becomes "/axis2/view?a=x y" after rewrite, and the backend won't be able to receive proper url due to the space in url. How can we preserve the url so that the backend target receives "/axis2/view?a=x%20y"?

<rewriter>
        <map from="^/bank/(.*)" to="/axis2/$1" />
</rewriter

victo...@gmail.com

unread,
Mar 27, 2015, 12:50:06 PM3/27/15
to membrane...@googlegroups.com, victo...@gmail.com
After some investigation I found it might be a bug in the URLUtil.java:

public static String getPathQuery(URIFactory uriFactory, String uri) {
URI u = uriFactory.createWithoutException(uri);
String query = u.getQuery(); // if change this to u.getRawQuery(); then everything works
return u.getPath() + (query == null ? "" : "?" + query);
}

However, I'm not sure if this is the designed behaviour or a bug? Maybe the u.getPath() should be replaced with u.getRawPath() and rename the whole method as getRawPathQuery()?

victo...@gmail.com

unread,
Apr 2, 2015, 12:50:21 PM4/2/15
to membrane...@googlegroups.com, victo...@gmail.com
So can we assume that the core/src/main/java/com/predic8/membrane/core/util/URLUtil.java should be updated to use RAW query in future updates, e.g. 4.0.21?

Thomas Bayer

unread,
Apr 14, 2015, 11:43:26 AM4/14/15
to membrane...@googlegroups.com, victo...@gmail.com
Hi Victor,
thanks for reporting and all the hints. 

That problem is really though. IMHO it should be possible to express the from pattern with -,+,space,... instead of the rewritten codes like %20. Manybe we should add URL encoding after rewriting.

Created an new issue:


Cheers,
Thomas  

victo...@gmail.com

unread,
Jun 16, 2015, 4:11:11 PM6/16/15
to membrane...@googlegroups.com, victo...@gmail.com
Just submitted a pull request for #187 - there is no need to re-encode the URL, all we need is to forward the original un-encoded URL to backend.
Reply all
Reply to author
Forward
0 new messages