// Force the status code to 200 events independently of the value of the entity (null or not)
if (response.getStatus() == 204) {
response.setStatus(200);
}
BroadcasterFactory broadcasterFactory = r.getAtmosphereConfig().getBroadcasterFactory();
boolean sessionSupported = (Boolean) servletReq.getAttribute(FrameworkConfig.SUPPORT_SESSION);
URI location = null;
// Do not add location header if already there.
if (useResumeAnnotation && !sessionSupported && !resumeOnBroadcast && response.getHttpHeaders().getFirst("Location") == null) {
String uuid = UUID.randomUUID().toString();
location = uriInfo.getAbsolutePathBuilder().path(uuid).build("");
resumeCandidates.put(uuid, r);
servletReq.setAttribute(RESUME_UUID, uuid);
servletReq.setAttribute(RESUME_CANDIDATES, resumeCandidates);
}
if (bc == null && localScope != Suspend.SCOPE.REQUEST) {
bc = r.getBroadcaster();
}
if (response.getEntity() == null) {
//https://github.com/Atmosphere/atmosphere/issues/423
response.setEntity("");
}
if (response.getEntity() instanceof Broadcastable) {
Broadcastable b = (Broadcastable) response.getEntity();
bc = b.getBroadcaster();
response.setEntity(b.getResponseMessage());
}
if ((localScope == Suspend.SCOPE.REQUEST) && bc == null) {
if (bc == null) {
try {
String id = servletReq.getHeader(X_ATMOSPHERE_TRACKING_ID);
if (id == null) {
id = UUID.randomUUID().toString();
}
bc = broadcasterFactory.get(id);
bc.setScope(Broadcaster.SCOPE.REQUEST);
} catch (Exception ex) {
logger.error("failed to instantiate broadcaster with factory: " + broadcasterFactory, ex);
}
} else {