Example usage for org.apache.http.config ConnectionConfig getFragmentSizeHint

List of usage examples for org.apache.http.config ConnectionConfig getFragmentSizeHint

Introduction

In this page you can find the example usage for org.apache.http.config ConnectionConfig getFragmentSizeHint.

Prototype

public int getFragmentSizeHint() 

Source Link

Usage

From source file:com.liferay.sync.engine.session.SyncManagedHttpClientConnectionFactory.java

@Override
public ManagedHttpClientConnection create(HttpRoute httpRoute, ConnectionConfig connectionConfig) {

    if (connectionConfig == null) {
        connectionConfig = ConnectionConfig.DEFAULT;
    }// w  w w.j  av a2 s. co m

    CharsetDecoder charsetDecoder = null;
    CharsetEncoder charsetEncoder = null;

    Charset charset = connectionConfig.getCharset();

    if (charset != null) {
        charsetDecoder = charset.newDecoder();
        charsetEncoder = charset.newEncoder();

        CodingErrorAction malformedInputAction = connectionConfig.getMalformedInputAction();

        if (malformedInputAction == null) {
            malformedInputAction = CodingErrorAction.REPORT;
        }

        charsetDecoder.onMalformedInput(malformedInputAction);
        charsetEncoder.onMalformedInput(malformedInputAction);

        CodingErrorAction unmappableInputAction = connectionConfig.getUnmappableInputAction();

        if (unmappableInputAction == null) {
            unmappableInputAction = CodingErrorAction.REPORT;
        }

        charsetDecoder.onUnmappableCharacter(unmappableInputAction);
        charsetEncoder.onUnmappableCharacter(unmappableInputAction);
    }

    return new SyncManagedHttpClientConnection("http-outgoing-" + _counter.getAndIncrement(),
            connectionConfig.getBufferSize(), connectionConfig.getFragmentSizeHint(), charsetDecoder,
            charsetEncoder, connectionConfig.getMessageConstraints(), null, null, null,
            DefaultHttpResponseParserFactory.INSTANCE);
}

From source file:org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.java

public ManagedHttpClientConnection create(final HttpRoute route, final ConnectionConfig config) {
    final ConnectionConfig cconfig = config != null ? config : ConnectionConfig.DEFAULT;
    CharsetDecoder chardecoder = null;
    CharsetEncoder charencoder = null;
    final Charset charset = cconfig.getCharset();
    final CodingErrorAction malformedInputAction = cconfig.getMalformedInputAction() != null
            ? cconfig.getMalformedInputAction()
            : CodingErrorAction.REPORT;
    final CodingErrorAction unmappableInputAction = cconfig.getUnmappableInputAction() != null
            ? cconfig.getUnmappableInputAction()
            : CodingErrorAction.REPORT;
    if (charset != null) {
        chardecoder = charset.newDecoder();
        chardecoder.onMalformedInput(malformedInputAction);
        chardecoder.onUnmappableCharacter(unmappableInputAction);
        charencoder = charset.newEncoder();
        charencoder.onMalformedInput(malformedInputAction);
        charencoder.onUnmappableCharacter(unmappableInputAction);
    }//from w w  w  . j  a  v a 2s .c  om
    final String id = "http-outgoing-" + Long.toString(COUNTER.getAndIncrement());
    return new LoggingManagedHttpClientConnection(id, log, headerlog, wirelog, cconfig.getBufferSize(),
            cconfig.getFragmentSizeHint(), chardecoder, charencoder, cconfig.getMessageConstraints(), null,
            null, requestWriterFactory, responseParserFactory);
}

From source file:org.apache.http.impl.nio.conn.DefaultClientAsyncConnectionFactory.java

@Override
public ManagedNHttpClientConnection create(final IOSession iosession, final ConnectionConfig config) {
    final String id = "http-outgoing-" + Long.toString(COUNTER.getAndIncrement());
    CharsetDecoder chardecoder = null;
    CharsetEncoder charencoder = null;
    final Charset charset = config.getCharset();
    final CodingErrorAction malformedInputAction = config.getMalformedInputAction() != null
            ? config.getMalformedInputAction()
            : CodingErrorAction.REPORT;
    final CodingErrorAction unmappableInputAction = config.getUnmappableInputAction() != null
            ? config.getUnmappableInputAction()
            : CodingErrorAction.REPORT;
    if (charset != null) {
        chardecoder = charset.newDecoder();
        chardecoder.onMalformedInput(malformedInputAction);
        chardecoder.onUnmappableCharacter(unmappableInputAction);
        charencoder = charset.newEncoder();
        charencoder.onMalformedInput(malformedInputAction);
        charencoder.onUnmappableCharacter(unmappableInputAction);
    }/*from  w  w  w .j a  v  a  2 s.  c o m*/
    final ManagedNHttpClientConnection conn = new ManagedNHttpClientConnectionImpl(id, this.log, this.headerlog,
            this.wirelog, iosession, config.getBufferSize(), config.getFragmentSizeHint(), this.allocator,
            chardecoder, charencoder, config.getMessageConstraints(), null, null, null,
            this.responseParserFactory);
    iosession.setAttribute(IOEventDispatch.CONNECTION_KEY, conn);
    return conn;
}

From source file:org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionFactory.java

@Override
public ManagedNHttpClientConnection create(final IOSession iosession, final ConnectionConfig config) {
    final String id = "http-outgoing-" + Long.toString(COUNTER.getAndIncrement());
    CharsetDecoder chardecoder = null;
    CharsetEncoder charencoder = null;
    final Charset charset = config.getCharset();
    final CodingErrorAction malformedInputAction = config.getMalformedInputAction() != null
            ? config.getMalformedInputAction()
            : CodingErrorAction.REPORT;
    final CodingErrorAction unmappableInputAction = config.getUnmappableInputAction() != null
            ? config.getUnmappableInputAction()
            : CodingErrorAction.REPORT;
    if (charset != null) {
        chardecoder = charset.newDecoder();
        chardecoder.onMalformedInput(malformedInputAction);
        chardecoder.onUnmappableCharacter(unmappableInputAction);
        charencoder = charset.newEncoder();
        charencoder.onMalformedInput(malformedInputAction);
        charencoder.onUnmappableCharacter(unmappableInputAction);
    }/*from  ww  w  . j a v  a  2s.c o  m*/
    final ManagedNHttpClientConnection conn = new ManagedNHttpClientConnectionImpl(id, this.log, this.headerlog,
            this.wirelog, iosession, config.getBufferSize(), config.getFragmentSizeHint(), this.allocator,
            chardecoder, charencoder, config.getMessageConstraints(), null, null, this.requestWriterFactory,
            this.responseParserFactory);
    iosession.setAttribute(IOEventDispatch.CONNECTION_KEY, conn);
    return conn;
}