Wicket
  1. Wicket
  2. WICKET-2732

Wicket redirects don't work with Apache JMeter

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4.6
    • Fix Version/s: 1.5-M1
    • Component/s: wicket
    • Labels:
    • Environment:
      Glassfish

      Description

      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

        Issue Links

          Activity

          Hide
          Alexander Fisher added a comment -

          The WICKET-2600 fix changes the redirect format from

          http://host/wicket-app/./ to http://host/wicket-app/.

          Neither of these work with JMeter.

          Show
          Alexander Fisher added a comment - The WICKET-2600 fix changes the redirect format from http://host/wicket-app/./ to http://host/wicket-app/ . Neither of these work with JMeter.
          Hide
          Sebb added a comment -

          Minor correction - JMeter works fine, it follows the redirect, but does not convert the location.

          The location appears to be an absolute URL, so is not converted by the call to java.net.URL.URL(URL context, String spec) .
          [JMeter calls this with the spec set to the Location: reference]

          Indeed some OSes may permit "." as a file name, so this AFAICS is the correct behaviour by JMeter.

          Wicket should ideally return a valid absolute URL, failing that it should return a valid relative URL.
          The current behaviour appears to be neither.

          Show
          Sebb added a comment - Minor correction - JMeter works fine, it follows the redirect, but does not convert the location. The location appears to be an absolute URL, so is not converted by the call to java.net.URL.URL(URL context, String spec) . [JMeter calls this with the spec set to the Location: reference] Indeed some OSes may permit "." as a file name, so this AFAICS is the correct behaviour by JMeter. Wicket should ideally return a valid absolute URL, failing that it should return a valid relative URL. The current behaviour appears to be neither.
          Hide
          Kai Grabfelder added a comment -

          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

          GET http://localhost/myappctx/document/create
          

          with a response like that

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

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

          /**
           * 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());
          		}
          		
          	}
          
          	
          }
          

          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

          Show
          Kai Grabfelder added a comment - 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 GET http: //localhost/myappctx/document/create with a response like that Response headers: HTTP/1.1 302 Moved Temporarily Server: Apache-Coyote/1.1 Location: http: //localhost/myappctx/document/../document/create.1 jmeter can't handle that. In order to workaround this behaviour I added the following servlet filter to my application. /** * 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()); } } } 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
          Hide
          Igor Vaynberg added a comment -

          this should already be fixed in 1.5

          Show
          Igor Vaynberg added a comment - this should already be fixed in 1.5
          Hide
          Martin Grigorov added a comment -

          Filed a bug at Tomcat issue tracker for this problem: https://issues.apache.org/bugzilla/show_bug.cgi?id=53062

          Show
          Martin Grigorov added a comment - Filed a bug at Tomcat issue tracker for this problem: https://issues.apache.org/bugzilla/show_bug.cgi?id=53062

            People

            • Assignee:
              Igor Vaynberg
              Reporter:
              Alexander Fisher
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development