You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by jyoti <jy...@viithiisys.com> on 2012/09/22 19:18:45 UTC

Url Rewrite Filter does not work on switching protocol

Hi,
    I have been working with url rewrite filter since last few days. All the
rules worked fine except outbound-rules. I faced following problem:-

When their was a http request none of the https links on the page were being
rewritten and in case of https request http links did not work.
The reason of this was that all the urls are rewritten only when encodeUrl()
function is called. And in ofbiz encodeUrl is not being called when there is
a protocol switch.

Following is the code of RequestHandler.java regarding this.
if (response != null && !forceManualJsessionid && !isSpider) {
                encodedUrl = response.encodeURL(newURL.toString());
            } else {
                if (!isSpider) {
                    String sessionId = ";jsessionid=" +
request.getSession().getId();
                    // this should be inserted just after the "?" for the
parameters, if there is one, or at the end of the string
                    int questionIndex = newURL.indexOf("?");
                    if (questionIndex == -1) {
                        newURL.append(sessionId);
                    } else {
                        newURL.insert(questionIndex, sessionId);
                    }
                }
                encodedUrl = newURL.toString();
            }
If we replace "encodedUrl = newURL.toString()" in the else portion with
"response.encodeURL(newURL.toString())" the problem is solved.

Should i submit this patch in the jira?





--
View this message in context: http://ofbiz.135035.n4.nabble.com/Url-Rewrite-Filter-does-not-work-on-switching-protocol-tp4636429.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Re: Url Rewrite Filter does not work on switching protocol

Posted by Jacques Le Roux <ja...@les7arts.com>.
Please yes submit a patch for review, even if what you say is quite clear, it's easier to focus/share there then
I guess you already know https://cwiki.apache.org/confluence/display/OFBADMIN/OFBiz+Contributors+Best+Practices ?

Thanks

Jacques

From: "jyoti" <jy...@viithiisys.com>
> Hi,
>    I have been working with url rewrite filter since last few days. All the
> rules worked fine except outbound-rules. I faced following problem:-
>
> When their was a http request none of the https links on the page were being
> rewritten and in case of https request http links did not work.
> The reason of this was that all the urls are rewritten only when encodeUrl()
> function is called. And in ofbiz encodeUrl is not being called when there is
> a protocol switch.
>
> Following is the code of RequestHandler.java regarding this.
> if (response != null && !forceManualJsessionid && !isSpider) {
>                encodedUrl = response.encodeURL(newURL.toString());
>            } else {
>                if (!isSpider) {
>                    String sessionId = ";jsessionid=" +
> request.getSession().getId();
>                    // this should be inserted just after the "?" for the
> parameters, if there is one, or at the end of the string
>                    int questionIndex = newURL.indexOf("?");
>                    if (questionIndex == -1) {
>                        newURL.append(sessionId);
>                    } else {
>                        newURL.insert(questionIndex, sessionId);
>                    }
>                }
>                encodedUrl = newURL.toString();
>            }
> If we replace "encodedUrl = newURL.toString()" in the else portion with
> "response.encodeURL(newURL.toString())" the problem is solved.
>
> Should i submit this patch in the jira?
>
>
>
>
>
> --
> View this message in context: 
> http://ofbiz.135035.n4.nabble.com/Url-Rewrite-Filter-does-not-work-on-switching-protocol-tp4636429.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.