Lift 2.4-M3 RedirectResponse and contextPath Rewriting

63 views
Skip to first unread message

arp

unread,
Aug 1, 2011, 12:11:37 AM8/1/11
to lif...@googlegroups.com
I recently upgraded to Lift 2.4-M3 when I began experiencing an interesting problem. My application is deployed under an the contextPath "/rm". When the application performs a RedirectResponse the Location header has a duplicated the contextPath as shown below in the Response Header section:

Request URL:http://localhost:8080/rm/
Request Method:GET
Status Code:302 Found


Request Headers
==========================================================================
Accept:application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Encoding:gzip, deflate
Accept-Language:en-au
User-Agent:Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-au) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1


Response Headers
==========================================================================
Cache-Control:no-cache, private, no-store
Content-Length:0
Content-Type:text/plain
Date:Mon, 1 Aug 2011 02:35:06 UTC
Expires:Mon, 1 Aug 2011 02:35:06 UTC
Location:/rm/rm/account/signin?F770706679337MZTQT2=_
Pragma:no-cache
Server:Jetty(7.4.4.v20110707)
X-Lift-Version:2.4-M3

After investigating the problem I found ticket #1054 made a change to the RedirectResponse that added the contextPath, however as part of the sendResponse method the same logic is performed again. The code fragment below is the fixHeaders method from line 651 of LiftServlet where the second contextPath rewriting is performed:

    def fixHeaders(headers: List[(String, String)]) = headers map ((v) => v match {

      case ("Location", uri) =>

        val u = request

        (v._1, (

          (for (

            updated <- Full((if (!LiftRules.excludePathFromContextPathRewriting.vend(uri)) u.contextPath else "") + uri).filter(ignore => uri.startsWith("/"));

            rwf <- URLRewriter.rewriteFunc) yield rwf(updated)) openOr uri

          ))

      case _ => v

    })


I implemented LiftRules.excludePathFromContextPathRewriting which stops the contextPath being rewritten a second time.

My question is should I raise a new ticket to alter the default behaviour to cater for the functionality introduced by ticket #1054?

Cheers.

Regards,

Andrew


David Pollak

unread,
Aug 1, 2011, 6:51:47 AM8/1/11
to lif...@googlegroups.com

Please open a new ticket referencing this thread and I will fix it.

Thanks!

> updated <- Full((if(!LiftRules.excludePathFromContextPathRewriting.vend(uri)) u.contextPath
> else "") + uri).filter(ignore => uri.startsWith("/"));
>
> rwf <- URLRewriter.rewriteFunc) yield rwf(updated)) openOr uri
>
> ))
>
> case _ => v
>
> })
>
> I implemented LiftRules.excludePathFromContextPathRewriting which stops the
> contextPath being rewritten a second time.
>
> My question is should I raise a new ticket to alter the default behaviour to
> cater for the functionality introduced by ticket #1054?
>
> Cheers.
>
> Regards,
>
> Andrew
>
>
> --
> You received this message because you are subscribed to the Google Groups "Lift" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/liftweb/-/I-fOm4Hn9EsJ.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
>

arp

unread,
Aug 2, 2011, 2:16:54 AM8/2/11
to lif...@googlegroups.com
David,

Thank you. I have created ticket #1082.

Regards,

Andrew
Reply all
Reply to author
Forward
0 new messages