// Temporarily replace the web response with a String response
final Response webResponse = getResponse();
try
{
final StringResponse response = new StringResponse();
getRequestCycle().setResponse(response);
IHeaderResponse headerResponse = getHeaderResponse();
if (!response.equals(headerResponse.getResponse()))
{
getRequestCycle().setResponse(headerResponse.getResponse());
}
// In any case, first render the header section directly associated
// with the markup
super.onComponentTagBody(markupStream, openTag);
// Render all header sections of all components on the page
AbstractHeaderRenderStrategy.get().renderHeader(this, getPage());
getHeaderResponse().close();
// Automatically add <head> if necessary
CharSequence output = response.getBuffer();
if (output.length() > 0)
{
if (output.charAt(0) == '\r')
{
for (int i = 2; i < output.length(); i += 2)