List of usage examples for org.apache.http.config ConnectionConfig getMalformedInputAction
public CodingErrorAction getMalformedInputAction()
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 . ja va2 s. c o 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.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); }// w ww .j av a 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 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); }/* ww w . jav a 2 s . co m*/ 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 ww w. ja va 2s. co 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); }//w w w .ja v a 2 s. c om 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; }