protected void addCometEvent(HttpEvent event) { if (this.event != null) { try { this.event.close(); } catch (IOException e) { // Nothing } } this.event = event; event.getHttpServletRequest().setAttribute(COMET_EVENT_ATTR,this); }
public static boolean isValid(HttpEvent event) { if (event != null) { try { return event.getHttpServletRequest() != null && event.getHttpServletResponse() != null; } catch (Exception e) { } } return false; }
public void event(HttpEvent event) throws IOException, ServletException { // make sure we've got a valid CometEvent (should never happen) if (!EventUtil.isValid(event)) { log.error("JBossWeb sent an invalid HttpEvent: %s", event.getType()); return; } if (log.isDebugEnabled()) { log.debug( "%s: %s/%s", event.getType(), event.getHttpServletRequest(), event.getHttpServletResponse() ); } if (event.getType() == HttpEvent.EventType.BEGIN) begin(event); else if (event.getType() == HttpEvent.EventType.READ) read(event); else if (event.getType() == HttpEvent.EventType.END) end(event); else if (event.getType() == HttpEvent.EventType.ERROR || event.getType() == HttpEvent.EventType.EOF || event.getType() == HttpEvent.EventType.TIMEOUT) error(event); else throw new ServletException("Unknown HttpEvent type: " + event.getType()); }
final HttpServletRequest request = event.getHttpServletRequest(); final HttpServletResponse response = event.getHttpServletResponse(); switch (event.getType()) { case BEGIN: event.setTimeout(20000); break; case ERROR: event.close(); break; case EVENT: case READ: while (event.isReadReady()) { onReceivedFrame((WebSocket) request.getAttribute(SESSION_WEBSOCKET_HANDLE)); event.resume(); break;
public void event(HttpEvent event) throws IOException, ServletException { HttpServletRequest req = event.getHttpServletRequest(); HttpServletResponse resp = event.getHttpServletResponse(); switch (event.getType()) { case BEGIN: break; case END: event.close(); break; case EOF: break; case ERROR: event.close(); break; case EVENT: do { inbound.onData(); } while (event.isReadReady()); break; case TIMEOUT:
/** * Return the servlet request for which this event occurred. */ public ServletRequest getRequest() { if (event != null) { return this.event.getHttpServletRequest(); } else { return (this.request); } }
public void event(HttpEvent cometEvent) throws IOException, ServletException { HttpEvent.EventType type = cometEvent.getType(); if (log.isTraceEnabled()) { log.trace("["+Thread.currentThread().getName()+"] Received Comet Event type="+type); } switch (type) { case BEGIN: cometEvent.setTimeout(getTimeout()); break; case READ: checkBayeux(cometEvent); break; case EOF: case EVENT: case WRITE: break; case ERROR: case END: case TIMEOUT: tb.remove(cometEvent); cometEvent.close(); break; } }//event
private void beginEvent(HttpEvent cometEvent) throws IOException, ServletException { HttpServletRequest request = cometEvent.getHttpServletRequest(); HttpServletResponse response = cometEvent.getHttpServletResponse(); if (session == null) { this.service(request, response); cometEvent.close(); return; log.debug("---addHangingGet: " + request.getSession() + '\n'); synchronized (pushable) { cometEvent.setTimeout((int)comet.getLongPollingTimeout()); pushable.setPushInfo(response); log.debug("---switchToPeriodicPolling: " + request.getSession() + '\n'); pushable.setPeriodicPolling(response); cometEvent.close(); cometEvent.close();
protected void begin(HttpEvent event) throws IOException, ServletException { boolean close = true; try { // Event timeout isn't supported with APR connectors... if (longPollingTimeoutSupported) { try { event.setTimeout((int)getLongPollingTimeout()); } catch (Exception e) { longPollingTimeoutSupported = false; } } HttpServletRequest request = event.getHttpServletRequest(); CometIO io = createCometIO(); io.readFully(request.getInputStream()); close = handleRequest(event, io.getInputStream()); } finally { if (close) { try { event.close(); } catch (Exception e) { log.debug(e, "Could not close event: %s", EventUtil.toString(event)); } } } }
HttpServletResponse response = null; try { request = event.getHttpServletRequest(); response = event.getHttpServletResponse(); } catch (Exception e) { log.warn(e, "Illegal event: %s", EventUtil.toString(event)); if (context == null) { try { event.close();
public static boolean isTimeout(HttpEvent event) { return (event.getType() == EventType.TIMEOUT); }
public void doClose() throws IOException{ event.close(); } });
/** * Perform the filtering that has been configured for this Filter, matching * against the specified request property. * * @param property The property to check against the allow/deny rules * @param event The comet event to be filtered * @param chain The comet filter chain * @exception IOException if an input/output error occurs * @exception ServletException if a servlet error occurs */ protected void processCometEvent(String property, HttpEvent event, HttpEventFilterChain chain) throws IOException, ServletException { HttpServletResponse response = event.getHttpServletResponse(); if (isAllowed(property)) { chain.doFilterEvent(event); } else { response.sendError(HttpServletResponse.SC_FORBIDDEN); event.close(); } }
/** * Return the servlet response for which this event occurred. */ public ServletResponse getResponse() { if (event != null) { return this.event.getHttpServletResponse(); } else { return (this.response); } }
int read = 0; if (block) { read = event.getHttpServletRequest().getInputStream().read(first, 0, 1); } else { if (event.isReadReady()) { read = event.getHttpServletRequest().getInputStream().read(first, 0, 1);
final HttpServletRequest request = event.getHttpServletRequest(); final HttpServletResponse response = event.getHttpServletResponse(); switch (event.getType()) { case BEGIN: event.setTimeout(20000); case ERROR: onSocketClosed((WebSocket) request.getAttribute(SESSION_WEBSOCKET_HANDLE)); event.close(); break; case EVENT: case READ: while (event.isReadReady()) { onReceivedFrame((WebSocket) request.getAttribute(SESSION_WEBSOCKET_HANDLE)); event.resume(); break;
protected void removeCometEvent(HttpEvent event) { if (this.event != null && this.event == event) { this.event = null; } event.getHttpServletRequest().removeAttribute(COMET_EVENT_ATTR); }
if (event.getType() == HttpEvent.EventType.BEGIN) { action = suspended(req, res); if (action.type == Action.TYPE.SUSPEND) { event.setTimeout((int) action.timeout); } else { event.setTimeout(Integer.MAX_VALUE); logger.fine("Resuming " + res); event.close(); } else { event.close(); } else if (event.getType() == HttpEvent.EventType.READ) { } else if (event.getType() == HttpEvent.EventType.ERROR) { event.close(); } else if (event.getType() == HttpEvent.EventType.END) { if (!resumed.remove(event)){ if (logger.isLoggable(Level.FINE)) { event.close(); } else if (event.getType() == HttpEvent.EventType.TIMEOUT) { if (logger.isLoggable(Level.FINE)){ logger.fine("Timing out " + res); event.close();
public static boolean isErrorButNotTimeout(HttpEvent event) { return event.getType() == EventType.ERROR; }
public void doClose() throws IOException { event.close(); } });