[ 
https://issues.apache.org/jira/browse/WICKET-2732?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12876213#action_12876213
 ] 

Kai Grabfelder commented on WICKET-2732:
----------------------------------------

We are having a slightly related problem here with a wicket application that 
uses org.apache.wicket.request.target.coding.HybridUrlCodingStrategy. 

If the application is deployed on tomcat (looks like we don't have the problem 
on jetty) is answering a request like this

{code}
GET http://localhost/myappctx/document/create
{code}

with a response like that

{code}
Response headers:
HTTP/1.1 302 Moved Temporarily
Server: Apache-Coyote/1.1
Location: http://localhost/myappctx/document/../document/create.1
{code}

jmeter can't handle that. In order to workaround this behaviour I added the 
following servlet filter to my application. 

{code}
/**
 * Servlet filter that converts wicket relative 302 redirects to absolute urls
 * (otherwhise jmeter can't load test a wicket app that is deployed on tomcat 
because it can't handle responses like 
 * 
HTTP/1.1 302 Moved Temporarily
Server: Apache-Coyote/1.1
Location: http://localhost/myappctx/document/../document/create.1
 * 
 * 
 * @author Kai Grabfelder
 *
 *...@see https://issues.apache.org/jira/browse/WICKET-2732 
 */
public class RelativeUrlFilter implements Filter {

        @Override
        public void destroy() {

        }

        @Override
        public void doFilter(ServletRequest request, ServletResponse response, 
FilterChain chain) throws IOException, ServletException {

                HttpServletRequest servletRequest = (HttpServletRequest) 
request;
                HttpServletResponse servletResponse = (HttpServletResponse) 
response;
                chain.doFilter(request, new 
RelativeUrlServletResponseFilter(servletRequest, servletResponse));
        }

        @Override
        public void init(FilterConfig filterConfig) throws ServletException {

        }

        public class RelativeUrlServletResponseFilter extends 
HttpServletResponseWrapper {
                private URI baseURL;
                public RelativeUrlServletResponseFilter(HttpServletRequest 
servletRequest, HttpServletResponse servletResponse) {
                        super(servletResponse);
                        try {
                                baseURL = new 
URI(servletRequest.getRequestURI());
                        } catch (URISyntaxException e) {
                                throw new RuntimeException(e);
                        }
                }
                
                @Override
                public void sendRedirect(String location) throws IOException {
                        URI newURL = baseURL.resolve(location);
                        super.sendRedirect(newURL.toString());
                }
                
        }

        
}
{code}

Please note that I haven't tested it extensivly yet (e.g. if it works if wicket 
is performing an absolute redirect). I'm even not sure if the tomcat behaviour 
(not converting the relative url to an absolute URL) is correct. Btw. the 
following thread is discussing the tomcat behaviour on the tomcat mailing list 
http://old.nabble.com/URLs-with-%27..-%27-and-404s-td28180099.html 



> Wicket redirects don't work with Apache JMeter
> ----------------------------------------------
>
>                 Key: WICKET-2732
>                 URL: https://issues.apache.org/jira/browse/WICKET-2732
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4.6
>         Environment: Glassfish
>            Reporter: Alexander Fisher
>             Fix For: 1.5-M1
>
>
> Unlike some browsers, JMeter does not fix up the broken URLs returned in the 
> Location header of 302 redirects generated by wicket.
> For instance, after signing out of a wicket 1.4.6 app, the redirect might be 
> to Location: http://host/wicket-app/.
> Some browsers and even some webservers will fix this up (removing the dot), 
> but JMeter will not and glassfish (and possibly other appservers) will return 
> a 404 error.
> I've have discussed the issue with the JMeter developer and hence opened this 
> ticket.
> http://mail-archives.apache.org/mod_mbox/jakarta-jmeter-user/201002.mbox/browser
> Many thanks,
> Alex

-- 
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