CaptureSearchResult result, Resource httpHeadersResource,
Resource payloadResource, ResultURIConverter uriConverter,
CaptureSearchResults results) throws ServletException, IOException,
WaybackException {
Resource decodedResource = TextReplayRenderer.decodeResource(httpHeadersResource, payloadResource);
// The URL of the page, for resolving in-page relative URLs:
URL url = null;
try {
url = new URL(result.getOriginalUrl());
} catch (MalformedURLException e1) {
// TODO: this shouldn't happen...
e1.printStackTrace();
throw new IOException(e1.getMessage());
}
// determine the character set used to encode the document bytes:
String charSet = charsetDetector.getCharset(httpHeadersResource, decodedResource, wbRequest);
ContextResultURIConverterFactory fact = createConverterFactory(uriConverter, httpRequest, wbRequest);
// set up the context:
ReplayParseContext context =
new ReplayParseContext(fact,url,result.getCaptureTimestamp());
context.setRewriteHttpsOnly(rewriteHttpsOnly);
if(!wbRequest.isFrameWrapperContext()) {
// in case this is an HTML page with FRAMEs, peek ahead an look:
// TODO: make ThreadLocal:
byte buffer[] = new byte[FRAMESET_SCAN_BUFFER_SIZE];
decodedResource.mark(FRAMESET_SCAN_BUFFER_SIZE);
int amtRead = decodedResource.read(buffer);
decodedResource.reset();
if(amtRead > 0) {
StringBuilder foo = new StringBuilder(new String(buffer,charSet));
int frameIdx = TagMagix.getEndOfFirstTag(foo, "FRAMESET");
if(frameIdx != -1) {