@Override public NextAction handleRead(FilterChainContext context) throws IOException { Object message = context.getMessage(); Connection<?> connection = context.getConnection(); Channel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { return context.getStopAction(); } else { if (savedReadIndex == frame.readerIndex()) { return context.getInvokeAction(); } else { return context.getInvokeAction(); return context.getInvokeAction();
@Override public NextAction handleWrite(final FilterChainContext ctx) throws IOException { final Object message = ctx.getMessage(); if (message instanceof HttpTransactionContext) { ctx.setMessage(null); if (!sendAsGrizzlyRequest((HttpTransactionContext) message, ctx)) { return ctx.getSuspendAction(); } else { return ctx.getStopAction(); } } return ctx.getInvokeAction(); }
@Override public NextAction handleEvent(final FilterChainContext ctx, final FilterChainEvent event) throws IOException { if (event.type() == GracefulCloseEvent.class) { // Connection was closed. // This event is fired only for responses, which don't have // associated transfer-encoding or content-length. // We have to complete such a request-response processing gracefully. final GracefulCloseEvent closeEvent = (GracefulCloseEvent) event; final HttpResponsePacket response = closeEvent.getHttpTxContext().responsePacket; response.getProcessingState().getHttpContext().attach(ctx); onHttpPacketParsed(response, ctx); return ctx.getStopAction(); } return ctx.getInvokeAction(); }
/** * {@inheritDoc} */ @Override public NextAction handleRead(FilterChainContext ctx) throws IOException { // a response is received - pass it to the callback final String responseMessage = ctx.getMessage(); callback.onResponseReceived(ctx.getConnection(), responseMessage); return ctx.getStopAction(); } }
@Override public NextAction handleEvent(final FilterChainContext ctx, final FilterChainEvent event) throws IOException { if (event.type() == SSLSwitchingEvent.class) { final SSLSwitchingEvent se = (SSLSwitchingEvent) event; final boolean isSecure = se.isSecure(); CONNECTION_IS_SECURE.set(se.getConnection(), isSecure); // if enabling security - create SSLEngine here, because default // Grizzly SSLFilter will use host/port info from the Connection, rather // than request URL. Specifically this doesn't work with CONNECT tunnels. if (isSecure && SSLUtils.getSSLEngine(ctx.getConnection()) == null) { // if SSLEngine is not yet set for the connection - initialize it final SSLEngine sslEngine = getClientSSLEngineConfigurator() .createSSLEngine(se.getHost(), se.getPort() == -1 ? 443 : se.getPort() ); sslEngine.beginHandshake(); SSLUtils.setSSLEngine(ctx.getConnection(), sslEngine); } return ctx.getStopAction(); } return ctx.getInvokeAction(); }
@Override public NextAction handleRead(final FilterChainContext ctx) throws IOException { ctx.getConnection().close(); return ctx.getStopAction(); } }
@Override public NextAction handleRead(FilterChainContext ctx) throws IOException { final GIOPMessage message = ctx.getMessage(); resultFuture.result(message); return ctx.getStopAction(); } }
@Override public NextAction handleRead(final FilterChainContext ctx) throws IOException { final Object message = ctx.getMessage(); final Connection connection = ctx.getConnection(); final Object address = ctx.getAddress(); if (logger.isLoggable(Level.FINEST)) { logger.log(Level.FINEST, "EchoFilter. connection={0} dstAddress={1} message={2}", new Object[]{connection, address, message}); } if (message instanceof Buffer) { ((Buffer) message).allowBufferDispose(true); } ctx.write(address, message, null); return ctx.getStopAction(); } }
@Override public NextAction handleRead(FilterChainContext context) throws IOException { Object message = context.getMessage(); Connection<?> connection = context.getConnection(); Channel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { return context.getStopAction(); } else { if (savedReadIndex == frame.readerIndex()) { return context.getInvokeAction(); } else { return context.getInvokeAction(); return context.getInvokeAction();
@Override @SuppressWarnings("unchecked") public NextAction handleEvent(final FilterChainContext ctx, final FilterChainEvent event) throws IOException { if (!Http2State.isHttp2(ctx.getConnection())) { return ctx.getInvokeAction(); } final Object type = event.type(); if (type == OutgoingHttpUpgradeEvent.TYPE) { assert event instanceof OutgoingHttpUpgradeEvent; final OutgoingHttpUpgradeEvent outUpgradeEvent = (OutgoingHttpUpgradeEvent) event; // If it's HTTP2 outgoing upgrade message - we have to re-enable content modifiers control outUpgradeEvent.getHttpHeader().setIgnoreContentModifiers(false); return ctx.getStopAction(); } return ctx.getInvokeAction(); }
@Override public NextAction handleRead(final FilterChainContext ctx) throws IOException { final Object message = ctx.getMessage(); // If the input message is not HttpContent or it's last HttpContent message - // pass the message to a next filter if (!(message instanceof HttpContent) || ((HttpContent) message).isLast()) { return ctx.getInvokeAction(); } // if it's HttpContent chunk (not last) - save it and stop filter chain processing. return ctx.getStopAction(message); } }
@Override public NextAction handleClose(final FilterChainContext ctx) throws IOException { final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR.remove(ctx.getConnection()); if (clientContext != null) { clientContext.handleClose(-1, null); } return ctx.getStopAction(); }
@Override public NextAction handleRead(FilterChainContext ctx) throws IOException { // Take ADD-service response final AddResponseMessage addResponseMessage = ctx.getMessage(); // do output LOGGER.log(Level.INFO, "Result={0}", addResponseMessage.getResult()); return ctx.getStopAction(); } }
@Override public NextAction handleEvent(FilterChainContext ctx, FilterChainEvent event) throws IOException { if (event.type() == SSLSwitchingEvent.class) { final SSLSwitchingEvent se = (SSLSwitchingEvent) event; CONNECTION_IS_SECURE.set(se.connection, se.secure); return ctx.getStopAction(); } return ctx.getInvokeAction(); }
@Override public NextAction handleRead(final FilterChainContext ctx) throws IOException { final Object message = ctx.getMessage(); final Connection connection = ctx.getConnection(); final Object address = ctx.getAddress(); if (logger.isLoggable(Level.FINEST)) { logger.log(Level.FINEST, "EchoFilter. connection={0} dstAddress={1} message={2}", new Object[]{connection, address, message}); } if (message instanceof Buffer) { ((Buffer) message).allowBufferDispose(true); } ctx.write(address, message, null); return ctx.getStopAction(); } }
@Override @SuppressWarnings("unchecked") public NextAction handleWrite(final FilterChainContext ctx) throws IOException { final Http2State http2State = Http2State.get(ctx.getConnection()); if (http2State == null || http2State.isNeverHttp2()) { return ctx.getInvokeAction(); } final Object message = ctx.getMessage(); final Http2Session http2Session = obtainHttp2Session(ctx, false); if (http2Session.isHttp2OutputEnabled() && HttpPacket.isHttp(message)) { // Get HttpPacket final HttpPacket httpPacket = ctx.getMessage(); final HttpHeader httpHeader = httpPacket.getHttpHeader(); processOutgoingHttpHeader(ctx, http2Session, httpHeader, httpPacket); } else { final TransportContext transportContext = ctx.getTransportContext(); http2Session.getOutputSink().writeDownStream(message, transportContext.getCompletionHandler(), transportContext.getMessageCloner()); } return ctx.getStopAction(); }
@Override @SuppressWarnings("unchecked") public NextAction handleEvent(final FilterChainContext ctx, final FilterChainEvent event) throws IOException { if (!Http2State.isHttp2(ctx.getConnection())) { return ctx.getInvokeAction(); } final Object type = event.type(); if (type == OutgoingHttpUpgradeEvent.TYPE) { assert event instanceof OutgoingHttpUpgradeEvent; final OutgoingHttpUpgradeEvent outUpgradeEvent = (OutgoingHttpUpgradeEvent) event; // If it's HTTP2 outgoing upgrade message - we have to re-enable content modifiers control outUpgradeEvent.getHttpHeader().setIgnoreContentModifiers(false); return ctx.getStopAction(); } return ctx.getInvokeAction(); }
@Override public NextAction handleRead(final FilterChainContext ctx) throws IOException { final Object message = ctx.getMessage(); // If the input message is not HttpContent or it's last HttpContent message - // pass the message to a next filter if (!(message instanceof HttpContent) || ((HttpContent) message).isLast()) { return ctx.getInvokeAction(); } // if it's HttpContent chunk (not last) - save it and stop filter chain processing. return ctx.getStopAction(message); } }
@Override public NextAction handleRead(final FilterChainContext ctx) throws IOException { ctx.getConnection().close(); return ctx.getStopAction(); } }
@Override public NextAction handleRead(FilterChainContext ctx) throws IOException { // Take SUB-service response final SubResponseMessage subResponseMessage = ctx.getMessage(); // do output LOGGER.log(Level.INFO, "Result={0}", subResponseMessage.getResult()); return ctx.getStopAction(); } }