jetty-9: HTTP client: allow configuration of sockets.
This commit is contained in:
parent
0ecd64a747
commit
be044015ff
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
|||
import java.net.ConnectException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.SocketException;
|
||||
import java.net.URI;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.SocketChannel;
|
||||
|
@ -120,6 +121,7 @@ public class HttpClient extends ContainerLifeCycle
|
|||
private volatile int maxRedirects = 8;
|
||||
private volatile SocketAddress bindAddress;
|
||||
private volatile long idleTimeout;
|
||||
private volatile boolean tcpNoDelay = true;
|
||||
|
||||
public HttpClient()
|
||||
{
|
||||
|
@ -314,7 +316,7 @@ public class HttpClient extends ContainerLifeCycle
|
|||
SocketAddress bindAddress = getBindAddress();
|
||||
if (bindAddress != null)
|
||||
channel.bind(bindAddress);
|
||||
channel.socket().setTcpNoDelay(true);
|
||||
configure(channel);
|
||||
channel.configureBlocking(false);
|
||||
channel.connect(new InetSocketAddress(destination.host(), destination.port()));
|
||||
|
||||
|
@ -329,6 +331,11 @@ public class HttpClient extends ContainerLifeCycle
|
|||
}
|
||||
}
|
||||
|
||||
protected void configure(SocketChannel channel) throws SocketException
|
||||
{
|
||||
channel.socket().setTcpNoDelay(isTCPNoDelay());
|
||||
}
|
||||
|
||||
private void close(SocketChannel channel)
|
||||
{
|
||||
try
|
||||
|
@ -507,6 +514,16 @@ public class HttpClient extends ContainerLifeCycle
|
|||
this.maxRedirects = maxRedirects;
|
||||
}
|
||||
|
||||
public boolean isTCPNoDelay()
|
||||
{
|
||||
return tcpNoDelay;
|
||||
}
|
||||
|
||||
public void setTCPNoDelay(boolean tcpNoDelay)
|
||||
{
|
||||
this.tcpNoDelay = tcpNoDelay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(Appendable out, String indent) throws IOException
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue