throws IOException
{
if (! _request.hasRequest())
return false;
HttpServletResponseImpl response = _request.getResponseFacade();
int statusCode = response.getStatus();
CharBuffer cb = _cb;
cb.clear();
cb.append((char) ((statusCode / 100) % 10 + '0'));
cb.append((char) ((statusCode / 10) % 10 + '0'));
cb.append((char) (statusCode % 10 + '0'));
cb.append(' ');
cb.append(response.getStatusMessage());
_req.writeStatus(cb);
if (statusCode >= 400) {
removeHeader("ETag");
removeHeader("Last-Modified");
}
else if (response.isNoCache()) {
removeHeader("ETag");
removeHeader("Last-Modified");
setHeader("Expires", "Thu, 01 Dec 1994 16:00:00 GMT");
_req.writeHeader("Cache-Control", "no-cache");
}
else if (response.isPrivateCache())
_req.writeHeader("Cache-Control", "private");
int load = (int) (1000 * _req.getServer().getCpuLoad());
if (Alarm.isTest())
load = 0;
_req.writeString(HmuxRequest.HMUX_META_HEADER, "cpu-load");
_req.writeString(HmuxRequest.HMUX_STRING, String.valueOf(load));
int size = _headerKeys.size();
for (int i = 0; i < size; i++) {
String key = (String) _headerKeys.get(i);
String value = (String) _headerValues.get(i);
_req.writeHeader(key, value);
}
if (_contentLength >= 0) {
cb.clear();
cb.append(_contentLength);
_req.writeHeader("Content-Length", cb);
}
else if (length >= 0) {
cb.clear();
cb.append(length);
_req.writeHeader("Content-Length", cb);
}
HttpServletResponseImpl responseFacade = _request.getResponseFacade();
long now = Alarm.getCurrentTime();
ArrayList<Cookie> cookiesOut = responseFacade.getCookies();
if (cookiesOut != null) {
size = cookiesOut.size();
for (int i = 0; i < size; i++) {
Cookie cookie = cookiesOut.get(i);
int cookieVersion = cookie.getVersion();
fillCookie(cb, cookie, now, 0, false);
_req.writeHeader("Set-Cookie", cb);
if (cookieVersion > 0) {
fillCookie(cb, cookie, now, cookieVersion, true);
_req.writeHeader("Set-Cookie2", cb);
}
}
}
String contentType = responseFacade.getContentTypeImpl();
String charEncoding = responseFacade.getCharacterEncodingImpl();
if (contentType != null) {
if (charEncoding != null)
_req.writeHeader("Content-Type", contentType + "; charset=" + charEncoding);
else