Author: markt Date: Mon Jul 6 22:20:11 2009 New Revision: 791634 URL: http://svn.apache.org/viewvc?rev=791634&view=rev Log: Make webDAV fix filter more sophisticated. Eventual aim is to provide fixes tailored to whichever broken client is trying to connect. Once I figure out how the client is broken of course. In the meantime, log when we know things go wrong. First up XP x64 SP2.
Modified: tomcat/trunk/java/org/apache/catalina/filters/WebdavFixFilter.java Modified: tomcat/trunk/java/org/apache/catalina/filters/WebdavFixFilter.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/filters/WebdavFixFilter.java?rev=791634&r1=791633&r2=791634&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/filters/WebdavFixFilter.java (original) +++ tomcat/trunk/java/org/apache/catalina/filters/WebdavFixFilter.java Mon Jul 6 22:20:11 2009 @@ -40,15 +40,37 @@ * * Generally each different version of the MS client has a different set of * problems. + * <p> * TODO: Update this filter to recognise specific MS clients and apply the * appropriate workarounds for that particular client - * + * <p> * As a filter, this is configured in web.xml like any other Filter. You usually * want to map this filter to whatever your WebDAV servlet is mapped to. + * <p> + * In addition to the issues fixed by this Filter, the following issues have + * also been observed that cannot be fixed by this filter. Where possible the + * filter will add an message to the logs. + * <p> + * XP x64 SP2 (MiniRedir Version 3790 + * <ul> + * <li>Only connects to port 80</li> + * <li>Requires an upper case context path</li> + * <li>Unknown issue means it doesn't work</li> + * </ul> */ public class WebdavFixFilter implements Filter { + private static final String LOG_MESSAGE_PREAMBLE = + "WebdavFixFilter: Detected client problem: "; + + /* Start string for all versions */ + private static final String UA_MINIDIR_START = + "Microsoft-WebDAV-MiniRedir"; + /* XP 64-bit SP2 */ + private static final String UA_MINIDIR_3790 = + "Microsoft-WebDAV-MiniRedir/5.2.3790"; + @Override public void init(FilterConfig filterConfig) throws ServletException { } @@ -72,10 +94,30 @@ HttpServletRequest httpRequest = ((HttpServletRequest) request); HttpServletResponse httpResponse = ((HttpServletResponse) response); String ua = httpRequest.getHeader("User-Agent"); - if (ua != null && ua.contains("MiniRedir")) { - httpResponse.sendRedirect(buildRedirect(httpRequest)); + + if (ua == null || ua.length() == 0 || + !ua.startsWith(UA_MINIDIR_START)) { + // No UA or starts with non MS value + // Hope everything just works... + chain.doFilter(request, response); + } else if (ua.startsWith(UA_MINIDIR_3790)) { + // XP 64-bit SP2 + // Check context path case + if (!httpRequest.getContextPath().equals( + httpRequest.getContextPath().toUpperCase())) { + log(request, + "XP-x64-SP2 expects context path to be upper case"); + } + // Some other, as yet unknown issue means I can't get this client + // to work + log(request, "XP-x64-SP2 is known not to work with WebDAV Servlet"); + + chain.doFilter(request, response); } else { - chain.doFilter(request, response); + // Don't know which MS client it is - try the redirect with an + // explicit port in the hope that it moves the client to a different + // WebDAV implementation that works + httpResponse.sendRedirect(buildRedirect(httpRequest)); } } @@ -94,4 +136,9 @@ return location.toString(); } + private void log(ServletRequest request, String msg) { + StringBuilder builder = new StringBuilder(LOG_MESSAGE_PREAMBLE); + builder.append(msg); + request.getServletContext().log(builder.toString()); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org