/** * Return the servlet request for which this event occurred. */ public ServletRequest getRequest() { if (event != null) { return this.event.getHttpServletRequest(); } else { return (this.request); } }
protected void removeCometEvent(HttpEvent event) { if (this.event != null && this.event == event) { this.event = null; } event.getHttpServletRequest().removeAttribute(COMET_EVENT_ATTR); }
protected void removeCometEvent(HttpEvent event) { if (this.event != null && this.event == event) { this.event = null; } event.getHttpServletRequest().removeAttribute(COMET_EVENT_ATTR); }
public int process(int prevops) throws BayeuxException { event.getHttpServletRequest().setAttribute(CURRENT_REQ_ATTR,this); return prevops; }
public int process(int prevops) throws BayeuxException { event.getHttpServletRequest().setAttribute(CURRENT_REQ_ATTR,this); return prevops; }
protected ClientImpl getClientImpl(HttpEvent event) { return (ClientImpl)event.getHttpServletRequest().getAttribute(ClientImpl.COMET_EVENT_ATTR); }
protected static JSONArray getJSONArray(HttpEvent event, boolean nullok) { synchronized(event) { JSONArray jarray = (JSONArray) event.getHttpServletRequest().getAttribute(JSON_MSG_ARRAY); if (jarray == null && (!nullok)) { jarray = new JSONArray(); event.getHttpServletRequest().setAttribute(JSON_MSG_ARRAY, jarray); } return jarray; } }
protected static JSONArray getJSONArray(HttpEvent event, boolean nullok) { synchronized(event) { JSONArray jarray = (JSONArray) event.getHttpServletRequest().getAttribute(JSON_MSG_ARRAY); if (jarray == null && (!nullok)) { jarray = new JSONArray(); event.getHttpServletRequest().setAttribute(JSON_MSG_ARRAY, jarray); } return jarray; } }
public static boolean isValid(HttpEvent event) { if (event != null) { try { return event.getHttpServletRequest() != null && event.getHttpServletResponse() != null; } catch (Exception e) { } } return false; }
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); }
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); }
private void blockingRead(HttpEvent event, ByteBuffer bb) throws IOException { int last = 0; while (bb.hasRemaining()) { last = event.getHttpServletRequest().getInputStream().read(); if (last == -1) { throw new IOException(MESSAGES.frameEos()); } bb.put((byte) (last ^ mask[bb.position() % 4])); } bb.flip(); }
private int blockingRead(HttpEvent event) throws IOException { int result = event.getHttpServletRequest().getInputStream().read(); if (result == -1) { throw new IOException(MESSAGES.frameEos()); } return result; }
private void blockingRead(HttpEvent event, byte[] bytes) throws IOException { int read = 0; int last = 0; while (read < bytes.length) { last = event.getHttpServletRequest().getInputStream().read(bytes, read, bytes.length - read); if (last == -1) { throw new IOException(MESSAGES.frameEos()); } read += last; } }
private void endEvent(HttpEvent cometEvent) throws IOException, ServletException { HttpServletRequest request = cometEvent.getHttpServletRequest(); log.debug("END: " + request.getSession() + '\n'); final Pushable pushable = getPushable(request); if (pushable != null) pushable.reset(); cometEvent.close(); }
private void handleTimeout(HttpEvent cometEvent) throws IOException, ServletException { HttpServletRequest request = cometEvent.getHttpServletRequest(); log.error("TIMEOUT: " + request.getSession() + '\n'); final Pushable pushable = getPushable(request); if (pushable != null) { synchronized (pushable) { pushable.reset(); pushable.reconnect(); } } cometEvent.close(); }
public MetaConnectRequest(TomcatBayeux tb, HttpEvent event, JSONObject jsReq) throws JSONException { super(tb, event, jsReq); if (clientId!=null && getTomcatBayeux().hasClient(clientId)) { event.getHttpServletRequest().setAttribute("client",getTomcatBayeux().getClient(clientId)); } }
public MetaConnectRequest(TomcatBayeux tb, HttpEvent event, JSONObject jsReq) throws JSONException { super(tb, event, jsReq); if (clientId!=null && getTomcatBayeux().hasClient(clientId)) { event.getHttpServletRequest().setAttribute("client",getTomcatBayeux().getClient(clientId)); } }
@Override public byte[] generateResponse(HttpEvent event) throws IOException { final HttpServletRequest request = event.getHttpServletRequest(); final HttpServletResponse response = event.getHttpServletResponse(); ORIGIN.copy(request, response); SEC_WEBSOCKET_PROTOCOL.copy(request, response); SEC_WEBSOCKET_LOCATION.set(response, getWebSocketLocation(request)); final String key = SEC_WEBSOCKET_KEY.get(request); final String solution = solve(key); WebSocketHeaders.SEC_WEBSOCKET_ACCEPT.set(response, solution); return new byte[0]; } }
@Override public byte[] generateResponse(HttpEvent event) throws IOException { final HttpServletRequest request = event.getHttpServletRequest(); final HttpServletResponse response = event.getHttpServletResponse(); if (ORIGIN.isIn(request)) { SEC_WEBSOCKET_ORIGIN.set(response, ORIGIN.get(request)); } SEC_WEBSOCKET_PROTOCOL.copy(request, response); SEC_WEBSOCKET_LOCATION.set(response, getWebSocketLocation(request)); final String key = SEC_WEBSOCKET_KEY.get(request); final String solution = solve(key); WebSocketHeaders.SEC_WEBSOCKET_ACCEPT.set(response, solution); return new byte[0]; }