Search in sources :

Example 1 with Http2SocketSession

use of com.generallycloud.baseio.codec.http2.Http2SocketSession in project baseio by generallycloud.

the class Http2PrefaceFuture method doComplete.

private void doComplete(SocketChannel channel, ByteBuf buf) throws IOException {
    Http2SocketSession session = (Http2SocketSession) channel.getSession();
    session.setPrefaceRead(false);
    if (!isPreface(buf)) {
        throw new IOException("not http2 preface");
    }
    session.doFlush(new DefaultChannelFuture(context, PREFACE_BUF.duplicate()));
}
Also used : Http2SocketSession(com.generallycloud.baseio.codec.http2.Http2SocketSession) DefaultChannelFuture(com.generallycloud.baseio.protocol.DefaultChannelFuture) IOException(java.io.IOException)

Example 2 with Http2SocketSession

use of com.generallycloud.baseio.codec.http2.Http2SocketSession in project baseio by generallycloud.

the class Http2HeadersFrameImpl method doComplete.

private void doComplete(SocketChannel channel, ByteBuf buf) throws IOException {
    Http2SocketSession session = (Http2SocketSession) channel.getSession();
    byte flags = getHeader().getFlags();
    this.endStream = (flags & FLAG_END_STREAM) > 0;
    if ((flags & FLAG_PADDED) > 0) {
        padLength = buf.getByte();
    }
    if ((flags & FLAG_PRIORITY) > 0) {
        streamDependency = buf.getInt();
        e = streamDependency < 0;
        if (e) {
            streamDependency = streamDependency & 0x7FFFFFFF;
        }
        weight = buf.getUnsignedByte();
    }
    decoder.decode(streamDependency, buf, session.getHttp2Headers());
}
Also used : Http2SocketSession(com.generallycloud.baseio.codec.http2.Http2SocketSession)

Example 3 with Http2SocketSession

use of com.generallycloud.baseio.codec.http2.Http2SocketSession in project baseio by generallycloud.

the class Http2SettingsFrameImpl method doComplete.

private void doComplete(SocketChannel channel, ByteBuf buf) throws IOException {
    Http2SocketSession session = (Http2SocketSession) channel.getSession();
    int settings = buf.limit() / 6;
    for (int i = 0; i < settings; i++) {
        int key = buf.getShort();
        int value = buf.getInt();
        session.setSettings(key, value);
    }
    this.settings = session.getSettings();
    channel.flush(this);
}
Also used : Http2SocketSession(com.generallycloud.baseio.codec.http2.Http2SocketSession)

Example 4 with Http2SocketSession

use of com.generallycloud.baseio.codec.http2.Http2SocketSession in project baseio by generallycloud.

the class Http2ProtocolDecoder method decode.

@Override
public ChannelFuture decode(SocketChannel channel, ByteBuf buffer) throws IOException {
    Http2SocketSession http2UnsafeSession = (Http2SocketSession) channel.getSession();
    SocketChannelContext context = channel.getContext();
    if (http2UnsafeSession.isPrefaceRead()) {
        return new Http2PrefaceFuture(context, allocate(channel, PROTOCOL_PREFACE_HEADER));
    }
    return new Http2FrameHeaderImpl(channel, allocate(channel, PROTOCOL_HEADER));
}
Also used : Http2FrameHeaderImpl(com.generallycloud.baseio.codec.http2.future.Http2FrameHeaderImpl) SocketChannelContext(com.generallycloud.baseio.component.SocketChannelContext) Http2PrefaceFuture(com.generallycloud.baseio.codec.http2.future.Http2PrefaceFuture)

Aggregations

Http2SocketSession (com.generallycloud.baseio.codec.http2.Http2SocketSession)3 Http2FrameHeaderImpl (com.generallycloud.baseio.codec.http2.future.Http2FrameHeaderImpl)1 Http2PrefaceFuture (com.generallycloud.baseio.codec.http2.future.Http2PrefaceFuture)1 SocketChannelContext (com.generallycloud.baseio.component.SocketChannelContext)1 DefaultChannelFuture (com.generallycloud.baseio.protocol.DefaultChannelFuture)1 IOException (java.io.IOException)1