Revision: 3476 http://archive-access.svn.sourceforge.net/archive-access/?rev=3476&view=rev Author: bradtofel Date: 2011-06-16 17:22:14 +0000 (Thu, 16 Jun 2011) Log Message: ----------- HACK allow redirection of URLs without timestamp to the current timestamp Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/ServerRelativeArchivalRedirect.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/ServerRelativeArchivalRedirect.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/ServerRelativeArchivalRedirect.java 2011-06-16 17:19:34 UTC (rev 3475) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/ServerRelativeArchivalRedirect.java 2011-06-16 17:22:14 UTC (rev 3476) @@ -29,6 +29,7 @@ import org.archive.net.UURI; import org.archive.net.UURIFactory; import org.archive.util.ArchiveUtils; +import org.archive.wayback.util.Timestamp; import org.archive.wayback.util.url.UrlOperations; import org.archive.wayback.util.webapp.AbstractRequestHandler; @@ -42,6 +43,7 @@ boolean useCollection = false; private String matchHost = null; private int matchPort = -1; + private String replayPrefix; private boolean handleRequestWithCollection(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws ServletException, @@ -154,9 +156,28 @@ return false; } } - return useCollection ? + boolean handled = useCollection ? handleRequestWithCollection(httpRequest, httpResponse): handleRequestWithoutCollection(httpRequest, httpResponse); + if(!handled) { + if(replayPrefix != null) { + String thisPath = httpRequest.getRequestURI(); + String queryString = httpRequest.getQueryString(); + if (queryString != null) { + thisPath += "?" + queryString; + } + if(thisPath.startsWith("/http://")) { + // assume a replay request: + StringBuilder sb = new StringBuilder(thisPath.length() + replayPrefix.length() + 16); + sb.append(replayPrefix); + sb.append(Timestamp.currentTimestamp().getDateStr()); + sb.append(thisPath); + httpResponse.sendRedirect(sb.toString()); + handled = true; + } + } + } + return handled; } /** @@ -195,4 +216,18 @@ public void setMatchPort(int matchPort) { this.matchPort = matchPort; } + + /** + * @return the replayPrefix + */ + public String getReplayPrefix() { + return replayPrefix; + } + + /** + * @param replayPrefix the replayPrefix to set + */ + public void setReplayPrefix(String replayPrefix) { + this.replayPrefix = replayPrefix; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |