From: <bra...@us...> - 2008-07-22 01:44:52
|
Revision: 2473 http://archive-access.svn.sourceforge.net/archive-access/?rev=2473&view=rev Author: bradtofel Date: 2008-07-22 01:45:01 +0000 (Tue, 22 Jul 2008) Log Message: ----------- REFACTOR: ReplayRenderer no longer ISA HttpHeaderProcessor, now they typically HAVE one. These two implementations represent the current HTTP processing which occurs for Proxy, ArchivalUrl, and DomainPrefix replay modes. Added Paths: ----------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/replay/IdentityHttpHeaderProcessor.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/replay/RedirectRewritingHttpHeaderProcessor.java Added: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/replay/IdentityHttpHeaderProcessor.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/replay/IdentityHttpHeaderProcessor.java (rev 0) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/replay/IdentityHttpHeaderProcessor.java 2008-07-22 01:45:01 UTC (rev 2473) @@ -0,0 +1,47 @@ +/* IdentityHttpHeaderProcessor + * + * $Id$ + * + * Created on 3:53:48 PM Jul 15, 2008. + * + * Copyright (C) 2008 Internet Archive. + * + * This file is part of wayback. + * + * wayback is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * any later version. + * + * wayback is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with wayback; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package org.archive.wayback.replay; + +import java.util.Map; + +import org.archive.wayback.ResultURIConverter; +import org.archive.wayback.core.CaptureSearchResult; + +/** + * HttpHeaderProcessor which passes through all headers as-is. + * + * @author brad + * @version $Date$, $Revision$ + */ +public class IdentityHttpHeaderProcessor implements HttpHeaderProcessor { + + /* (non-Javadoc) + * @see org.archive.wayback.replay.HttpHeaderProcessor#filter(java.util.Map, java.lang.String, java.lang.String, org.archive.wayback.ResultURIConverter, org.archive.wayback.core.CaptureSearchResult) + */ + public void filter(Map<String, String> output, String key, String value, + ResultURIConverter uriConverter, CaptureSearchResult result) { + output.put(key, value); + } +} Added: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/replay/RedirectRewritingHttpHeaderProcessor.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/replay/RedirectRewritingHttpHeaderProcessor.java (rev 0) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/replay/RedirectRewritingHttpHeaderProcessor.java 2008-07-22 01:45:01 UTC (rev 2473) @@ -0,0 +1,69 @@ +/* RedirectRewritingHttpHeaderProcessor + * + * $Id$ + * + * Created on 3:00:48 PM Jul 15, 2008. + * + * Copyright (C) 2008 Internet Archive. + * + * This file is part of wayback. + * + * wayback is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * any later version. + * + * wayback is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with wayback; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package org.archive.wayback.replay; + +import java.util.Map; + +import org.archive.wayback.ResultURIConverter; +import org.archive.wayback.core.CaptureSearchResult; +import org.archive.wayback.util.url.UrlOperations; + +/** + * + * + * @author brad + * @version $Date$, $Revision$ + */ +public class RedirectRewritingHttpHeaderProcessor + implements HttpHeaderProcessor { + + /* (non-Javadoc) + * @see org.archive.wayback.replay.HttpHeaderProcessor#filter(java.util.Map, java.lang.String, java.lang.String, org.archive.wayback.ResultURIConverter, org.archive.wayback.core.CaptureSearchResult) + */ + public void filter(Map<String, String> output, String key, String value, + ResultURIConverter uriConverter, CaptureSearchResult result) { + + String keyUp = key.toUpperCase(); + + // rewrite Location header URLs + if (keyUp.startsWith(HTTP_LOCATION_HEADER_UP) || + keyUp.startsWith(HTTP_CONTENT_BASE_HEADER_UP)) { + + String baseUrl = result.getOriginalUrl(); + String cd = result.getCaptureTimestamp(); + // by the spec, these should be absolute already, but just in case: + String u = UrlOperations.resolveUrl(baseUrl, value); + + output.put(key, uriConverter.makeReplayURI(cd,u)); +// } else if(keyUp.startsWith(HTTP_CONTENT_TYPE_HEADER_UP)) { +// output.put("X-Wayback-Orig-" + key,value); +// output.put(key,value); + } else { + // others go out as-is: + + output.put(key, value); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |