List of usage examples for org.apache.http.nio.reactor IOSession setAttribute
void setAttribute(String name, Object obj);
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); }/* w w w . jav 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, 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); }/* ww w . ja v a2 s . 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, this.requestWriterFactory, this.responseParserFactory); iosession.setAttribute(IOEventDispatch.CONNECTION_KEY, conn); return conn; }
From source file:org.apache.synapse.transport.http.conn.ClientConnFactory.java
public DefaultNHttpClientConnection createConnection(final IOSession iosession, final HttpRoute route) { IOSession customSession;// w w w . j a va 2 s . com if (ssl != null && route.isSecure() && !route.isTunnelled()) { SSLContext customContext = getSSLContext(iosession); SSLIOSession ssliosession = new SSLIOSession(iosession, SSLMode.CLIENT, customContext, ssl.getHandler()); iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession); customSession = ssliosession; } else { if (route != null && route.isTunnelled()) { org.apache.http.HttpHost httpHost = route.getTargetHost(); String beAddress = null; String proxyAdd = null; if (httpHost != null) { String hostname = httpHost.getHostName(); int port = httpHost.getPort(); beAddress = hostname + ":" + port; } org.apache.http.HttpHost proxyHost = route.getProxyHost(); if (proxyHost != null) { String proxyHostName = proxyHost.getHostName(); int proxyPort = proxyHost.getPort(); proxyAdd = proxyHostName + ":" + proxyPort; } if (sslByHostMap != null && sslByHostMap.containsKey(beAddress)) { SSLContext beCtx = sslByHostMap.get(beAddress); sslByHostMap.put(proxyAdd, beCtx); } } customSession = iosession; } DefaultNHttpClientConnection conn = LoggingUtils.createClientConnection(customSession, responseFactory, allocator, params); int timeout = HttpConnectionParams.getSoTimeout(params); conn.setSocketTimeout(timeout); return conn; }