List of usage examples for org.apache.http.conn.scheme LayeredSocketFactory LayeredSocketFactory
LayeredSocketFactory
From source file:com.LaunchKeyManager.http.AsyncHttpClient.java
private SocketFactory workAroundReverseDnsBugInHoneycombAndEarlier() { // Android had a bug where HTTPS made reverse DNS lookups (fixed in Ice Cream Sandwich) // http://code.google.com/p/android/issues/detail?id=13117 return new LayeredSocketFactory() { SSLSocketFactory delegate = SSLSocketFactory.getSocketFactory(); @Override/*from w ww .j a v a2s.c o m*/ public Socket createSocket() throws IOException { return delegate.createSocket(); } @Override public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException { return delegate.connectSocket(sock, host, port, localAddress, localPort, params); } @Override public boolean isSecure(Socket sock) throws IllegalArgumentException { return delegate.isSecure(sock); } @Override public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException { injectHostname(socket, host); return delegate.createSocket(socket, host, port, autoClose); } private void injectHostname(Socket socket, String host) { try { Field field = InetAddress.class.getDeclaredField("hostName"); field.setAccessible(true); field.set(socket.getInetAddress(), host); } catch (Exception ignored) { } } }; }