Package org.archive.wayback.replay

Examples of org.archive.wayback.replay.HTMLPage


    HttpHeaderOperation.copyHTTPMessageHeader(resource, httpResponse);

    Map<String,String> headers = HttpHeaderOperation.processHeaders(resource, result, uriConverter, this);

    // Load content into an HTML page, and resolve load-time URLs:
    HTMLPage page = new HTMLPage(resource,result,uriConverter);
    page.readFully();
   
    if(serverSideRendering) {
      page.resolveAllPageUrls();
    } else {
      page.resolvePageUrls();
    }
    if(jsInserts != null) {
      Iterator<String> itr = jsInserts.iterator();
      while(itr.hasNext()) {
        toInsert.append(page.getJSIncludeString(itr.next()));
      }
    }
    if(jspInserts != null) {
      Iterator<String> itr = jspInserts.iterator();
      while(itr.hasNext()) {
        toInsert.append(page.includeJspString(itr.next(), httpRequest,
            httpResponse, wbRequest, results, result));
      }
    }

    // insert the new content:
    if(serverSideRendering) {
      page.insertAtStartOfBody(toInsert.toString());
    } else {
      page.insertAtEndOfBody(toInsert.toString());
    }
   
    // set the corrected length:
    int bytes = page.getBytes().length;
    headers.put(HTTP_LENGTH_HEADER, String.valueOf(bytes));
    // Tomcat will always send a charset... It's trying to be smarter than
    // we are. If the original page didn't include a "charset" as part of
    // the "Content-Type" HTTP header, then Tomcat will use the default..
    // who knows what that is, or what that will do to the page..
    // let's try explicitly setting it to what we used:
    httpResponse.setCharacterEncoding(page.getCharSet());

    // send back the headers:
    HttpHeaderOperation.sendHeaders(headers, httpResponse);

    page.writeToOutputStream(httpResponse.getOutputStream());
   
    // log this replay request
    logReplayRequest(httpRequest, httpRequest.getParameter("sid"));
  }
View Full Code Here


    Map<String,String> headers = HttpHeaderOperation.processHeaders(
        resource, result, uriConverter, this);

    // Load content into an HTML page, and resolve load-time URLs:
    HTMLPage page = new HTMLPage(resource,result,uriConverter);
    page.readFully();

    String resourceTS = result.getCaptureDate();
    String captureTS = Timestamp.parseBefore(resourceTS).getDateStr();
   
   
    StringBuilder sb = page.sb;
    StringBuffer replaced = new StringBuffer(sb.length());
    Matcher m = httpPattern.matcher(sb);
    while(m.find()) {
      String host = m.group(1);
      String replacement = uriConverter.makeReplayURI(captureTS,host);
      m.appendReplacement(replaced, replacement);
    }
    m.appendTail(replaced);
    byte b[] = replaced.toString().getBytes(page.getCharSet());
    int bytes = b.length;
    headers.put(HTTP_LENGTH_HEADER, String.valueOf(bytes));

    HttpHeaderOperation.sendHeaders(headers, httpResponse);
    httpResponse.getOutputStream().write(b);
View Full Code Here

    Map<String,String> headers = HttpHeaderOperation.processHeaders(
        resource, result, uriConverter, this);
 
    // Load content into an HTML page, and resolve @import URLs:
    HTMLPage page = new HTMLPage(resource,result,uriConverter);
    page.readFully();

    page.resolveCSSUrls();

    // set the corrected length:
    int bytes = page.getBytes().length;
    headers.put(HTTP_LENGTH_HEADER, String.valueOf(bytes));

    // send back the headers:
    HttpHeaderOperation.sendHeaders(headers, httpResponse);

    page.writeToOutputStream(httpResponse.getOutputStream());
  }
View Full Code Here

TOP

Related Classes of org.archive.wayback.replay.HTMLPage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.