From: <bra...@us...> - 2009-05-20 02:51:40
|
Revision: 2728 http://archive-access.svn.sourceforge.net/archive-access/?rev=2728&view=rev Author: bradtofel Date: 2009-05-20 02:51:34 +0000 (Wed, 20 May 2009) Log Message: ----------- FEATURE: Now attempts to determine the referring page for badly resolved server-relative URLs within a page, re-resolving against the referring URL, and redirecting to the (hopefully) correct URL. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java 2009-05-20 02:49:24 UTC (rev 2727) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java 2009-05-20 02:51:34 UTC (rev 2728) @@ -37,12 +37,12 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.httpclient.URIException; +import org.archive.net.UURI; +import org.archive.net.UURIFactory; import org.archive.wayback.exception.ConfigurationException; +import org.archive.wayback.util.url.UrlOperations; -//import org.archive.wayback.core.WaybackRequest; -//import org.archive.wayback.exception.BadQueryException; -//import org.archive.wayback.exception.ConfigurationException; - /** * * @@ -102,9 +102,55 @@ boolean handled = false; RequestContext context = mapper.mapContext(httpRequest); - if(context != null) { + if(context == null) { + try { + handled = + handleServerRelativeArchivalRedirect(httpRequest, httpResponse); + } catch(URIException e) { + // TODO: Log this? + handled = false; + } + } else { handled = context.handleRequest(httpRequest,httpResponse); } return handled; } + + private boolean handleServerRelativeArchivalRedirect( + HttpServletRequest httpRequest, HttpServletResponse httpResponse) + throws IOException { + + boolean handled = false; + // hope that it's a server relative request, with a valid referrer: + String referer = httpRequest.getHeader("Referer"); + if(referer != null) { + UURI uri = UURIFactory.getInstance(referer); + String path = uri.getPath(); + int secondSlash = path.indexOf('/',1); + if(secondSlash > -1) { + String collection = path.substring(0,secondSlash); + String remainder = path.substring(secondSlash+1); + int thirdSlash = remainder.indexOf('/'); + if(thirdSlash > -1) { + String datespec = remainder.substring(0,thirdSlash); + String url = remainder.substring(thirdSlash+1); + String thisPath = httpRequest.getRequestURI(); + String resolved = UrlOperations.resolveUrl(url, thisPath); + String contextPath = httpRequest.getContextPath(); + String finalUrl = uri.getScheme() + "://" + + uri.getAuthority() + contextPath + collection + "/" + + datespec + "/" + resolved; + // cross your fingers!!! + LOGGER.info("Server-Relative-Redirect:\t" + referer + "\t" + + thisPath + "\t" + finalUrl); + httpResponse.sendRedirect(finalUrl); + handled = true; + + } + } + } + + return handled; + + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bra...@us...> - 2009-10-15 22:34:03
|
Revision: 2807 http://archive-access.svn.sourceforge.net/archive-access/?rev=2807&view=rev Author: bradtofel Date: 2009-10-15 22:33:53 +0000 (Thu, 15 Oct 2009) Log Message: ----------- TWEAK: removed unused import. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java 2009-10-15 22:32:38 UTC (rev 2806) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java 2009-10-15 22:33:53 UTC (rev 2807) @@ -25,7 +25,6 @@ package org.archive.wayback.webapp; import java.io.IOException; -import java.util.TimeZone; import java.util.logging.Logger; import javax.servlet.Filter; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bra...@us...> - 2009-11-11 00:34:26
|
Revision: 2925 http://archive-access.svn.sourceforge.net/archive-access/?rev=2925&view=rev Author: bradtofel Date: 2009-11-11 00:14:29 +0000 (Wed, 11 Nov 2009) Log Message: ----------- BUGFIX(unreported) now includes query string when performing server-relative archival URL redirects using referrer info. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java 2009-11-11 00:13:00 UTC (rev 2924) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java 2009-11-11 00:14:29 UTC (rev 2925) @@ -133,6 +133,11 @@ String datespec = remainder.substring(0,thirdSlash); String url = remainder.substring(thirdSlash+1); String thisPath = httpRequest.getRequestURI(); + String queryString = httpRequest.getQueryString(); + if (queryString != null) { + thisPath += "?" + queryString; + } + String resolved = UrlOperations.resolveUrl(url, thisPath); String contextPath = httpRequest.getContextPath(); String finalUrl = uri.getScheme() + "://" + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bra...@us...> - 2010-03-19 21:18:55
|
Revision: 2983 http://archive-access.svn.sourceforge.net/archive-access/?rev=2983&view=rev Author: bradtofel Date: 2010-03-19 21:18:47 +0000 (Fri, 19 Mar 2010) Log Message: ----------- BUGFIX(unreported): adding http:// if missing for server-relative redirect Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java 2010-03-19 02:19:23 UTC (rev 2982) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java 2010-03-19 21:18:47 UTC (rev 2983) @@ -39,6 +39,7 @@ import org.apache.log4j.Logger; import org.archive.net.UURI; import org.archive.net.UURIFactory; +import org.archive.util.ArchiveUtils; import org.archive.wayback.exception.ConfigurationException; import org.archive.wayback.util.url.UrlOperations; @@ -131,7 +132,8 @@ int thirdSlash = remainder.indexOf('/'); if(thirdSlash > -1) { String datespec = remainder.substring(0,thirdSlash); - String url = remainder.substring(thirdSlash+1); + String url = ArchiveUtils.addImpliedHttpIfNecessary( + remainder.substring(thirdSlash+1)); String thisPath = httpRequest.getRequestURI(); String queryString = httpRequest.getQueryString(); if (queryString != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bra...@us...> - 2010-04-05 23:36:54
|
Revision: 3028 http://archive-access.svn.sourceforge.net/archive-access/?rev=3028&view=rev Author: bradtofel Date: 2010-04-05 23:36:47 +0000 (Mon, 05 Apr 2010) Log Message: ----------- BUGFIX(unreported) added Vary header to try to keep server-relative redirects from getting improperly cached. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java 2010-04-05 23:25:55 UTC (rev 3027) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java 2010-04-05 23:36:47 UTC (rev 3028) @@ -148,6 +148,10 @@ // cross your fingers!!! LOGGER.info("Server-Relative-Redirect:\t" + referer + "\t" + thisPath + "\t" + finalUrl); + + // Gotta make sure this is properly cached, or + // weird things happen: + httpResponse.addHeader("Vary", "Referer"); httpResponse.sendRedirect(finalUrl); handled = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |