public class ServerRelativeArchivalRedirect extends AbstractRequestHandler
ServerRelativeArchivalRedirect
is a RequestHandler
that redirects leaked server-relative URL back to replay request
URL.
For example, assuming Referer
is
http://web.archive.org/web/20010203040506/http://example.com/index.html
,
it redirects request http://web.archive.org/js/foo.js
to http://web.archive.org/web/20010203040506/http://example.com/js/foo.js
.
It is typically set up as catch-all RequestHandler
Refactoring Thoughts: parsing and construction of Archival-URL in this class must match that of Archival-URL access point. Consider delegating those to AccessPoint for easier configuration.
Modifier and Type | Class and Description |
---|---|
static class |
ServerRelativeArchivalRedirect.ArchivalUrlRef
A little helper class for passing parsed Archival-URL.
|
Constructor and Description |
---|
ServerRelativeArchivalRedirect() |
Modifier and Type | Method and Description |
---|---|
String |
getMatchHost() |
int |
getMatchPort() |
protected ServerRelativeArchivalRedirect.ArchivalUrlRef |
getOrigin(javax.servlet.http.HttpServletRequest httpRequest)
Return the Archival-URL projection of request origin, that
should give a context necessary to redirect the leaked request
back to Archival-URL space.
|
String |
getReplayPrefix() |
boolean |
handleRequest(javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse)
Possibly handle an incoming HttpServletRequest, much like a normal
HttpServlet, but includes a return value.
|
boolean |
isUseCollection() |
protected String |
modifyCollection(String collection)
modify collection if necessary.
|
void |
setMatchHost(String matchHost)
optional host name
Referer URL should match. |
void |
setMatchPort(int matchPort)
optional port number
Referer URL should match. |
void |
setReplayPrefix(String replayPrefix)
optional replay URL prefix used by fallback method.
|
void |
setUseCollection(boolean useCollection)
whether replay URL has collection part.
|
getAccessPointPath, getBeanName, getInternalPort, getMapParam, getMapParamOrEmpty, getRequiredMapParam, getServletContext, registerPortListener, setAccessPointPath, setBeanName, setInternalPort, setServletContext, translateRequestPath, translateRequestPathQuery
protected ServerRelativeArchivalRedirect.ArchivalUrlRef getOrigin(javax.servlet.http.HttpServletRequest httpRequest)
Default implementation parses Referer
header.
Sub class may override this method to use alternative method
of obtaining equivalent information. Typically you want to
call super method first, then resort to alternative method
if super method returns null
or incomplete info.
httpRequest
- request objectnull
if valid information cannot be found.protected String modifyCollection(String collection)
default implementation simply return collection
.
collection
- (the first path component of Referer URL.)
note value has leading slash, which must be retained.public boolean handleRequest(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse) throws javax.servlet.ServletException, IOException
RequestHandler
httpRequest
- the incoming HttpServletRequesthttpResponse
- the HttpServletResponse to return data to the client.javax.servlet.ServletException
- for usual reasons.IOException
- for usual reasons.public boolean isUseCollection()
public void setUseCollection(boolean useCollection)
set this to true
if replay URL has collection
part, path component between context path and timestamp (although
it's called collection based on the common usage of this part,
there's no need to have particular semantics.)
collection part will be passed to modifyCollection(String)
before constructing final replay URL to redirect to.
useCollection
- the useCollection to setpublic String getMatchHost()
public void setMatchHost(String matchHost)
Referer
URL should match.matchHost
- the matchHost to setpublic int getMatchPort()
public void setMatchPort(int matchPort)
Referer
URL should match.matchPort
- the matchPort to setpublic String getReplayPrefix()
public void setReplayPrefix(String replayPrefix)
replayPrefix
- the replayPrefix to setCopyright © 2005–2017 IIPC. All rights reserved.