Field field = null;
try {
/* based on class SecureConnectionManager.Outbound */
field = request.getClass().getDeclaredField("c");
field.setAccessible(true);
Connection c =
(Connection) field.get(request);
field = c.getClass().getDeclaredField("sslSocket");
field.setAccessible(true);
socket = (SSLSocket)field.get(c);
} catch (Exception e) {
if (field == null) {
try {
/* based on class HttpsServerEndpoint.HtttpsOutboundRequest */
field = request.getClass().getDeclaredField("connection");
field.setAccessible(true);
Connection c =(Connection) field.get(request);
field = c.getClass().getSuperclass()
.getDeclaredField("sslSocket");
field.setAccessible(true);
socket = (SSLSocket)field.get(c);
} catch (Exception eHttp) {
eHttp.printStackTrace();