public void setRequest(HttpServletRequest request) {
this.request = request;
}
public int sendNotification(Notification notification, Client connection,boolean first) throws IOException {
String pathInfo = notification.getPathInfo();
InnerResponse innerResponse = new InnerResponse(prefix + pathInfo);
ObservedCall call = notification.getCall();
innerResponse.setHeader("Event", call.getMethod());
IndividualRequest request = connection.getIndividualRequest(null, response);
request.setRequestedPath(pathInfo, Identification.idForString(pathInfo));
Object target = call.getContent();
String output;
if (target == Scriptable.NOT_FOUND || target == Undefined.instance){
innerResponse.setStatus(204);
output ="";
}
else
output = request.serialize(target);
innerResponse.setHeader("Last-Modified", "" + new Date()); // TODO: This should come from the transaction
innerResponse.getOutputStream().print(output);
String message = innerResponse.asString();
response.getOutputStream().print(message);
response.getOutputStream().flush();
return message.length();
}