Example usage for org.apache.http.impl.conn DefaultHttpResponseParserFactory INSTANCE

List of usage examples for org.apache.http.impl.conn DefaultHttpResponseParserFactory INSTANCE

Introduction

In this page you can find the example usage for org.apache.http.impl.conn DefaultHttpResponseParserFactory INSTANCE.

Prototype

DefaultHttpResponseParserFactory INSTANCE

To view the source code for org.apache.http.impl.conn DefaultHttpResponseParserFactory INSTANCE.

Click 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;
    }//from   w ww . j  a va 2s.c om

    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.archive.modules.fetcher.FetchHTTPRequest.java

protected HttpClientConnectionManager buildConnectionManager() {
    Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
            .register("http", PlainConnectionSocketFactory.INSTANCE).register("https",
                    new SSLConnectionSocketFactory(fetcher.sslContext(), new AllowAllHostnameVerifier()) {

                        @Override
                        public Socket createLayeredSocket(final Socket socket, final String target,
                                final int port, final HttpContext context) throws IOException {

                            return super.createLayeredSocket(socket, isDisableSNI() ? "" : target, port,
                                    context);
                        }/*from   ww w  .java 2  s .c om*/
                    })
            .build();

    DnsResolver dnsResolver = new ServerCacheResolver(fetcher.getServerCache());

    ManagedHttpClientConnectionFactory connFactory = new ManagedHttpClientConnectionFactory() {
        private static final int DEFAULT_BUFSIZE = 8 * 1024;

        @Override
        public ManagedHttpClientConnection create(HttpRoute route, 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);
            }
            return new RecordingHttpClientConnection(DEFAULT_BUFSIZE, DEFAULT_BUFSIZE, chardecoder, charencoder,
                    cconfig.getMessageConstraints(), null, null, DefaultHttpRequestWriterFactory.INSTANCE,
                    DefaultHttpResponseParserFactory.INSTANCE);
        }
    };
    BasicHttpClientConnectionManager connMan = new BasicHttpClientConnectionManager(socketFactoryRegistry,
            connFactory, null, dnsResolver);

    SocketConfig.Builder socketConfigBuilder = SocketConfig.custom();
    socketConfigBuilder.setSoTimeout(fetcher.getSoTimeoutMs());
    connMan.setSocketConfig(socketConfigBuilder.build());

    return connMan;
}

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

public ManagedHttpClientConnectionFactory(final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
        final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
    super();//w ww . j av a  2s  .  co m
    this.requestWriterFactory = requestWriterFactory != null ? requestWriterFactory
            : DefaultHttpRequestWriterFactory.INSTANCE;
    this.responseParserFactory = responseParserFactory != null ? responseParserFactory
            : DefaultHttpResponseParserFactory.INSTANCE;
}