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"));
}