use of org.apache.http.nio.reactor.IOSession in project wso2-synapse by wso2.
the class PassThroughHttpSenderTest method testSubmitResponse.
/**
* This method tests the submitting of response when the source request is null
* @throws Exception
*/
@Test
public void testSubmitResponse() throws Exception {
MockitoAnnotations.initMocks(this);
MessageContext messageContext = new MessageContext();
messageContext.setProperty(Constants.Configuration.TRANSPORT_URL, "http://sample.url");
messageContext.setProperty(NhttpConstants.FORCE_HTTP_CONTENT_LENGTH, true);
messageContext.setProperty(PassThroughConstants.COPY_CONTENT_LENGTH_FROM_INCOMING, true);
messageContext.setProperty(PassThroughConstants.ORGINAL_CONTEN_LENGTH, "1000");
messageContext.setOperationContext(new OperationContext());
IOSession session = PowerMockito.mock(IOSession.class);
NHttpServerConnection conn = new DefaultNHttpServerConnection(session, 12);
messageContext.setProperty(PassThroughConstants.PASS_THROUGH_SOURCE_CONNECTION, conn);
messageContext.setProperty(PassThroughConstants.HTTP_ETAG_ENABLED, true);
Map headers = new HashMap();
headers.put("randomKey", "randomValue");
messageContext.setProperty(MessageContext.TRANSPORT_HEADERS, headers);
sender = PowerMockito.spy(sender);
PowerMockito.when(digestGenerator.getDigest(any(MessageContext.class))).thenReturn("testString");
sender.submitResponse(messageContext);
}
use of org.apache.http.nio.reactor.IOSession in project wso2-synapse by wso2.
the class ClientConnFactory method upgrade.
public void upgrade(final UpgradableNHttpConnection conn) {
if (ssl != null) {
IOSession iosession = conn.getIOSession();
if (!(iosession instanceof SSLIOSession)) {
SSLContext customContext = getSSLContext(iosession);
SSLIOSession ssliosession = createClientModeSSLsession(iosession, customContext);
iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
conn.bind(ssliosession);
}
}
}
use of org.apache.http.nio.reactor.IOSession in project wso2-synapse by wso2.
the class ClientConnFactory method upgrade.
public void upgrade(final UpgradableNHttpConnection conn, HttpRoute route) {
org.apache.http.HttpHost targetHost = route.getTargetHost();
if (ssl != null) {
IOSession iosession = conn.getIOSession();
if (!(iosession instanceof SSLIOSession)) {
SSLContext customContext = getSSLContext(targetHost);
SSLIOSession ssliosession = createClientModeSSLsession(iosession, customContext);
iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
conn.bind(ssliosession);
}
}
}
use of org.apache.http.nio.reactor.IOSession in project wso2-synapse by wso2.
the class ClientConnFactory method createConnection.
public DefaultNHttpClientConnection createConnection(final IOSession iosession, final HttpRoute route) {
IOSession customSession;
if (ssl != null && route.isSecure() && !route.isTunnelled()) {
SSLContext customContext = getSSLContext(iosession);
SSLIOSession ssliosession = createClientModeSSLsession(iosession, customContext);
iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
customSession = ssliosession;
} else {
customSession = iosession;
}
DefaultNHttpClientConnection conn = LoggingUtils.createClientConnection(customSession, responseFactory, allocator, params);
int timeout = HttpConnectionParams.getSoTimeout(params);
conn.setSocketTimeout(timeout);
return conn;
}
use of org.apache.http.nio.reactor.IOSession in project wso2-synapse by wso2.
the class ServerConnFactory method createConnection.
public DefaultNHttpServerConnection createConnection(final IOSession iosession) {
SSLContextDetails customSSL = null;
if (sslByIPMap != null) {
customSSL = sslByIPMap.get(iosession.getLocalAddress());
if (customSSL == null && allNetworkAddress != null) {
customSSL = sslByIPMap.get(allNetworkAddress);
}
}
if (customSSL == null) {
customSSL = ssl;
}
IOSession customSession;
if (customSSL != null) {
customSession = new SSLIOSession(iosession, SSLMode.SERVER, customSSL.getContext(), customSSL.getHandler());
iosession.setAttribute(SSLIOSession.SESSION_KEY, customSession);
} else {
customSession = iosession;
}
DefaultNHttpServerConnection conn = LoggingUtils.createServerConnection(customSession, requestFactory, allocator, params);
int timeout = HttpConnectionParams.getSoTimeout(params);
conn.setSocketTimeout(timeout);
return conn;
}
Aggregations