static Http2State create(final Connection connection) { final Http2State state = new Http2State(); http2State.set(connection, state); return state; }
private Http2State doDirectUpgrade(final FilterChainContext ctx) { final Connection connection = ctx.getConnection(); final Http2Session http2Session = new Http2Session(connection, true, this); // Create HTTP/2.0 connection for the given Grizzly Connection final Http2State http2State = Http2State.create(connection); http2State.setHttp2Session(http2Session); http2State.setDirectUpgradePhase(); http2Session.setupFilterChains(ctx, true); // server preface http2Session.sendPreface(); return http2State; }
public static Http2Session get(final Connection connection) { final Http2State http2State = Http2State.get(connection); return http2State != null ? http2State.getHttp2Session() : null; }
@Override public void onComplete(final FilterChainContext context) { if (http2State.tryLockClientPreface()) { final Http2Session http2Session = http2State.getHttp2Session(); assert http2Session != null; http2Session.sendPreface(); } } });
Http2State http2State = Http2State.get(connection); if (http2State != null && http2State.isNeverHttp2()) { return ctx.getInvokeAction(); http2State = Http2State.create(connection); final Object msg = ctx.getMessage(); http2State.setNeverHttp2(); if (http2State.isHttpUpgradePhase()) {
Http2State http2State = Http2State.get(connection); if (http2State == null || http2State.isNeverHttp2()) { final HttpHeader httpHeader = httpContent.getHttpHeader(); if (http2State.isHttpUpgradePhase()) { // Not HTTP/2 (yet?) assert !httpHeader.isRequest(); http2State.setNeverHttp2(); return ctx.getInvokeAction(); http2State.getFrameParsingState(), framePayload);
Http2State http2State = Http2State.get(connection); if (http2State != null && http2State.isNeverHttp2()) { Http2State.create(connection).setNeverHttp2(); return ctx.getInvokeAction(); if (!http2Session.isHttp2InputEnabled()) { // Preface is not received yet if (http2State.isHttpUpgradePhase()) { http2State.setDirectUpgradePhase(); // expecting preface enableOpReadNow(ctx); http2State.getFrameParsingState(), framePayload);
final Http2State state = Http2State.get(ctx.getConnection()); if (state == null || state.isNeverHttp2()) { return ctx.getInvokeAction(); state.finishHttpUpgradePhase(); // mark HTTP upgrade as finished (in case it's still on)
final Http2Session http2Session = createClientHttp2Session(connection); final Http2State state = http2Session.getHttp2State(); state.setDirectUpgradePhase(); http2Session.sendPreface(); final NextAction suspendAction = ctx.getSuspendAction(); ctx.suspend(); state.addReadyListener(new Http2State.ReadyListener() { @Override public void ready(Http2Session http2Session) {
static boolean isHttp2(final Connection connection) { final Http2State state = http2State.get(connection); return state != null && state.isHttp2(); }
@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(); }
static Http2State obtain(final Connection connection) { Http2State state = http2State.get(connection); if (state == null) { state = create(connection); } return state; }
boolean isHttp2() { return !isNeverHttp2(); }
Http2State http2State = Http2State.get(connection); if (http2State != null && http2State.isNeverHttp2()) { return ctx.getInvokeAction(); http2State = Http2State.create(connection); final Object msg = ctx.getMessage(); http2State.setNeverHttp2(); if (http2State.isHttpUpgradePhase()) {
Http2State http2State = Http2State.get(connection); if (http2State == null || http2State.isNeverHttp2()) { final HttpHeader httpHeader = httpContent.getHttpHeader(); if (http2State.isHttpUpgradePhase()) { // Not HTTP/2 (yet?) assert !httpHeader.isRequest(); http2State.setNeverHttp2(); return ctx.getInvokeAction(); http2State.getFrameParsingState(), framePayload);
Http2State http2State = Http2State.get(connection); if (http2State != null && http2State.isNeverHttp2()) { Http2State.create(connection).setNeverHttp2(); return ctx.getInvokeAction(); if (!http2Session.isHttp2InputEnabled()) { // Preface is not received yet if (http2State.isHttpUpgradePhase()) { http2State.setDirectUpgradePhase(); // expecting preface enableOpReadNow(ctx); http2State.getFrameParsingState(), framePayload);
final Http2State state = Http2State.get(ctx.getConnection()); if (state == null || state.isNeverHttp2()) { return ctx.getInvokeAction(); state.finishHttpUpgradePhase(); // mark HTTP upgrade as finished (in case it's still on)
final Http2Session http2Session = createClientHttp2Session(connection); final Http2State state = http2Session.getHttp2State(); state.setDirectUpgradePhase(); http2Session.sendPreface(); final NextAction suspendAction = ctx.getSuspendAction(); ctx.suspend(); state.addReadyListener(new Http2State.ReadyListener() { @Override public void ready(Http2Session http2Session) {
@Override public void onComplete(final FilterChainContext context) { if (http2State.tryLockClientPreface()) { final Http2Session http2Session = http2State.getHttp2Session(); assert http2Session != null; http2Session.sendPreface(); } } });
static boolean isHttp2(final Connection connection) { final Http2State state = http2State.get(connection); return state != null && state.isHttp2(); }