List of usage examples for org.apache.http.impl.io DefaultHttpRequestWriterFactory INSTANCE
DefaultHttpRequestWriterFactory INSTANCE
To view the source code for org.apache.http.impl.io DefaultHttpRequestWriterFactory INSTANCE.
Click Source Link
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. co m }) .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();/*from w w w . j a v a 2s. com*/ this.requestWriterFactory = requestWriterFactory != null ? requestWriterFactory : DefaultHttpRequestWriterFactory.INSTANCE; this.responseParserFactory = responseParserFactory != null ? responseParserFactory : DefaultHttpResponseParserFactory.INSTANCE; }