< prev index next >
src/java.base/share/classes/java/net/HttpConnectSocketImpl.java
Print this page
*** 50,59 ****
--- 50,60 ----
private static final Field serverSocketField;
private static final Method doTunneling;
private final String server;
private InetSocketAddress external_address;
+ private final Socket socket;
private HashMap<Integer, Object> optionsMap = new HashMap<>();
static {
try {
Class<?> httpClazz = Class.forName(httpURLClazzStr, true, null);
*** 73,91 ****
} catch (ReflectiveOperationException x) {
throw new InternalError("Should not reach here", x);
}
}
! HttpConnectSocketImpl(Proxy proxy, SocketImpl delegate) {
super(delegate);
SocketAddress a = proxy.address();
if ( !(a instanceof InetSocketAddress) )
throw new IllegalArgumentException("Unsupported address type");
InetSocketAddress ad = (InetSocketAddress) a;
server = ad.getHostString();
port = ad.getPort();
}
@Override
protected void connect(String host, int port) throws IOException {
connect(new InetSocketAddress(host, port), 0);
--- 74,93 ----
} catch (ReflectiveOperationException x) {
throw new InternalError("Should not reach here", x);
}
}
! HttpConnectSocketImpl(Proxy proxy, SocketImpl delegate, Socket socket) {
super(delegate);
SocketAddress a = proxy.address();
if ( !(a instanceof InetSocketAddress) )
throw new IllegalArgumentException("Unsupported address type");
InetSocketAddress ad = (InetSocketAddress) a;
server = ad.getHostString();
port = ad.getPort();
+ this.socket = socket;
}
@Override
protected void connect(String host, int port) throws IOException {
connect(new InetSocketAddress(host, port), 0);
*** 95,115 ****
protected void connect(InetAddress address, int port) throws IOException {
connect(new InetSocketAddress(address, port), 0);
}
@Override
- void setSocket(Socket socket) {
- delegate.socket = socket;
- super.setSocket(socket);
- }
-
- @Override
- void setServerSocket(ServerSocket socket) {
- throw new InternalError("should not get here");
- }
-
- @Override
protected void connect(SocketAddress endpoint, int timeout)
throws IOException
{
if (endpoint == null || !(endpoint instanceof InetSocketAddress))
throw new IllegalArgumentException("Unsupported address type");
--- 97,106 ----
*** 135,145 ****
// close the original socket impl and release its descriptor
close();
// update the Sockets impl to the impl from the http Socket
SocketImpl si = httpSocket.impl;
! getSocket().setImpl(si);
// best effort is made to try and reset options previously set
Set<Map.Entry<Integer,Object>> options = optionsMap.entrySet();
try {
for(Map.Entry<Integer,Object> entry : options) {
--- 126,136 ----
// close the original socket impl and release its descriptor
close();
// update the Sockets impl to the impl from the http Socket
SocketImpl si = httpSocket.impl;
! socket.setImpl(si); // TODO REMOVE: Is this ok, or delegating?
// best effort is made to try and reset options previously set
Set<Map.Entry<Integer,Object>> options = optionsMap.entrySet();
try {
for(Map.Entry<Integer,Object> entry : options) {
< prev index next >