Search in sources :

Example 1 with DefaultNHttpClientConnection

use of org.apache.http.impl.nio.DefaultNHttpClientConnection in project wso2-synapse by wso2.

the class ClientHandler method getErrorMessage.

/**
 * Include remote host and port information to an error message
 *
 * @param message the initial message
 * @param conn the connection encountering the error
 * @return the updated error message
 */
private String getErrorMessage(String message, NHttpClientConnection conn) {
    if (conn != null && conn instanceof DefaultNHttpClientConnection) {
        DefaultNHttpClientConnection c = ((DefaultNHttpClientConnection) conn);
        Axis2HttpRequest axis2Request = (Axis2HttpRequest) conn.getContext().getAttribute(AXIS2_HTTP_REQUEST);
        if (c.getRemoteAddress() != null) {
            return message + " For : " + c.getRemoteAddress().getHostAddress() + ":" + c.getRemotePort() + (axis2Request != null ? " For Request : " + axis2Request : "");
        }
    }
    return message;
}
Also used : DefaultNHttpClientConnection(org.apache.http.impl.nio.DefaultNHttpClientConnection)

Example 2 with DefaultNHttpClientConnection

use of org.apache.http.impl.nio.DefaultNHttpClientConnection 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 = new SSLIOSession(iosession, SSLMode.CLIENT, customContext, ssl.getHandler());
        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;
}
Also used : SSLIOSession(org.apache.http.nio.reactor.ssl.SSLIOSession) SSLIOSession(org.apache.http.nio.reactor.ssl.SSLIOSession) IOSession(org.apache.http.nio.reactor.IOSession) SSLContext(javax.net.ssl.SSLContext) DefaultNHttpClientConnection(org.apache.http.impl.nio.DefaultNHttpClientConnection)

Aggregations

DefaultNHttpClientConnection (org.apache.http.impl.nio.DefaultNHttpClientConnection)2 SSLContext (javax.net.ssl.SSLContext)1 IOSession (org.apache.http.nio.reactor.IOSession)1 SSLIOSession (org.apache.http.nio.reactor.ssl.SSLIOSession)1