Java Code Examples for io.undertow.connector.ByteBufferPool#allocate()

The following examples show how to use io.undertow.connector.ByteBufferPool#allocate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Http2ClearClientProvider.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static String createSettingsFrame(OptionMap options, ByteBufferPool bufferPool) {
    PooledByteBuffer b = bufferPool.allocate();
    try {
        ByteBuffer currentBuffer = b.getBuffer();

        if (options.contains(UndertowOptions.HTTP2_SETTINGS_HEADER_TABLE_SIZE)) {
            pushOption(currentBuffer, Http2Setting.SETTINGS_HEADER_TABLE_SIZE, options.get(UndertowOptions.HTTP2_SETTINGS_HEADER_TABLE_SIZE));
        }
        if (options.contains(UndertowOptions.HTTP2_SETTINGS_ENABLE_PUSH)) {
            pushOption(currentBuffer, Http2Setting.SETTINGS_ENABLE_PUSH, options.get(UndertowOptions.HTTP2_SETTINGS_ENABLE_PUSH) ? 1 : 0);
        }

        if (options.contains(UndertowOptions.HTTP2_SETTINGS_MAX_CONCURRENT_STREAMS)) {
            pushOption(currentBuffer, Http2Setting.SETTINGS_MAX_CONCURRENT_STREAMS, options.get(UndertowOptions.HTTP2_SETTINGS_MAX_CONCURRENT_STREAMS));
        }

        if (options.contains(UndertowOptions.HTTP2_SETTINGS_INITIAL_WINDOW_SIZE)) {
            pushOption(currentBuffer, Http2Setting.SETTINGS_INITIAL_WINDOW_SIZE, options.get(UndertowOptions.HTTP2_SETTINGS_INITIAL_WINDOW_SIZE));
        }

        if (options.contains(UndertowOptions.HTTP2_SETTINGS_MAX_FRAME_SIZE)) {
            pushOption(currentBuffer, Http2Setting.SETTINGS_MAX_FRAME_SIZE, options.get(UndertowOptions.HTTP2_SETTINGS_MAX_FRAME_SIZE));
        }

        if (options.contains(UndertowOptions.HTTP2_SETTINGS_MAX_HEADER_LIST_SIZE)) {
            pushOption(currentBuffer, Http2Setting.SETTINGS_MAX_HEADER_LIST_SIZE, options.get(UndertowOptions.HTTP2_SETTINGS_MAX_HEADER_LIST_SIZE));
        } else if(options.contains(UndertowOptions.MAX_HEADER_SIZE)) {
            pushOption(currentBuffer, Http2Setting.SETTINGS_MAX_HEADER_LIST_SIZE, options.get(UndertowOptions.HTTP2_SETTINGS_MAX_HEADER_LIST_SIZE));
        }
        currentBuffer.flip();
        return FlexBase64.encodeStringURL(currentBuffer, false);
    } finally {
        b.close();
    }
}
 
Example 2
Source File: AjpOpenListener.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public AjpOpenListener(final ByteBufferPool pool, final OptionMap undertowOptions) {
    this.undertowOptions = undertowOptions;
    this.bufferPool = pool;
    PooledByteBuffer buf = pool.allocate();
    this.bufferSize = buf.getBuffer().remaining();
    buf.close();
    parser = new AjpRequestParser(undertowOptions.get(URL_CHARSET, StandardCharsets.UTF_8.name()), undertowOptions.get(DECODE_URL, true), undertowOptions.get(UndertowOptions.MAX_PARAMETERS, UndertowOptions.DEFAULT_MAX_PARAMETERS), undertowOptions.get(UndertowOptions.MAX_HEADERS, UndertowOptions.DEFAULT_MAX_HEADERS), undertowOptions.get(UndertowOptions.ALLOW_ENCODED_SLASH, false), undertowOptions.get(UndertowOptions.ALLOW_UNESCAPED_CHARACTERS_IN_URL, false));
    connectorStatistics = new ConnectorStatisticsImpl();
    statisticsEnabled = undertowOptions.get(UndertowOptions.ENABLE_CONNECTOR_STATISTICS, false);
}
 
Example 3
Source File: Http2OpenListener.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public Http2OpenListener(final ByteBufferPool pool, final OptionMap undertowOptions, String protocol) {
    this.undertowOptions = undertowOptions;
    this.bufferPool = pool;
    PooledByteBuffer buf = pool.allocate();
    this.bufferSize = buf.getBuffer().remaining();
    buf.close();
    connectorStatistics = new ConnectorStatisticsImpl();
    statisticsEnabled = undertowOptions.get(UndertowOptions.ENABLE_STATISTICS, false);
    this.protocol = protocol;
}
 
Example 4
Source File: HttpOpenListener.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public HttpOpenListener(final ByteBufferPool pool, final OptionMap undertowOptions) {
    this.undertowOptions = undertowOptions;
    this.bufferPool = pool;
    PooledByteBuffer buf = pool.allocate();
    this.bufferSize = buf.getBuffer().remaining();
    buf.close();
    parser = HttpRequestParser.instance(undertowOptions);
    connectorStatistics = new ConnectorStatisticsImpl();
    statisticsEnabled = undertowOptions.get(UndertowOptions.ENABLE_CONNECTOR_STATISTICS, false);
}
 
Example 5
Source File: ChunkedStreamSourceConduit.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public ChunkedStreamSourceConduit(final StreamSourceConduit next, final PushBackStreamSourceConduit channel, final ByteBufferPool pool, final ConduitListener<? super ChunkedStreamSourceConduit> finishListener, Attachable attachable, Closeable closeable) {
    this(next, new BufferWrapper() {
        @Override
        public PooledByteBuffer allocate() {
            return pool.allocate();
        }

        @Override
        public void pushBack(PooledByteBuffer pooled) {
            channel.pushBack(new PooledAdaptor(pooled));
        }
    }, finishListener, attachable, null, closeable);
}