HttpTunnelClientSocket -> HttpTunnelingClientSocket
HttpTunnelSocket -> HttpTunnelingSocket
This commit is contained in:
parent
5699f2e18e
commit
3922fb8a44
@ -35,9 +35,9 @@ import org.jboss.netty.channel.ChannelFuture;
|
||||
* @version $Rev$, $Date$
|
||||
*/
|
||||
class HttpTunnelWorker implements Runnable {
|
||||
private final HttpTunnelClientSocketChannel channel;
|
||||
private final HttpTunnelingClientSocketChannel channel;
|
||||
|
||||
HttpTunnelWorker(HttpTunnelClientSocketChannel channel) {
|
||||
HttpTunnelWorker(HttpTunnelingClientSocketChannel channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ class HttpTunnelWorker implements Runnable {
|
||||
}
|
||||
|
||||
static void write(
|
||||
HttpTunnelClientSocketChannel channel, ChannelFuture future,
|
||||
HttpTunnelingClientSocketChannel channel, ChannelFuture future,
|
||||
Object message) {
|
||||
|
||||
try {
|
||||
@ -99,7 +99,7 @@ class HttpTunnelWorker implements Runnable {
|
||||
}
|
||||
|
||||
static void setInterestOps(
|
||||
HttpTunnelClientSocketChannel channel, ChannelFuture future, int interestOps) {
|
||||
HttpTunnelingClientSocketChannel channel, ChannelFuture future, int interestOps) {
|
||||
|
||||
// Override OP_WRITE flag - a user cannot change this flag.
|
||||
interestOps &= ~Channel.OP_WRITE;
|
||||
@ -136,7 +136,7 @@ class HttpTunnelWorker implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
static void close(HttpTunnelClientSocketChannel channel, ChannelFuture future) {
|
||||
static void close(HttpTunnelingClientSocketChannel channel, ChannelFuture future) {
|
||||
boolean connected = channel.isConnected();
|
||||
boolean bound = channel.isBound();
|
||||
try {
|
||||
|
@ -55,7 +55,7 @@ import org.jboss.netty.util.LinkedTransferQueue;
|
||||
* @author Andy Taylor (andy.taylor@jboss.org)
|
||||
* @version $Rev$, $Date$
|
||||
*/
|
||||
class HttpTunnelClientSocketChannel extends AbstractChannel
|
||||
class HttpTunnelingClientSocketChannel extends AbstractChannel
|
||||
implements org.jboss.netty.channel.socket.SocketChannel {
|
||||
|
||||
private final Lock reconnectLock = new ReentrantLock();
|
||||
@ -78,11 +78,11 @@ class HttpTunnelClientSocketChannel extends AbstractChannel
|
||||
|
||||
private final DelimiterBasedFrameDecoder handler = new DelimiterBasedFrameDecoder(8092, ChannelBuffers.wrappedBuffer(new byte[] { '\r', '\n' }));
|
||||
|
||||
private final HttpTunnelClientSocketChannel.ServletChannelHandler servletHandler = new ServletChannelHandler();
|
||||
private final HttpTunnelingClientSocketChannel.ServletChannelHandler servletHandler = new ServletChannelHandler();
|
||||
|
||||
private HttpTunnelAddress remoteAddress;
|
||||
|
||||
HttpTunnelClientSocketChannel(
|
||||
HttpTunnelingClientSocketChannel(
|
||||
ChannelFactory factory,
|
||||
ChannelPipeline pipeline,
|
||||
ChannelSink sink, ClientSocketChannelFactory clientSocketChannelFactory) {
|
||||
@ -150,26 +150,26 @@ class HttpTunnelClientSocketChannel extends AbstractChannel
|
||||
SocketAddress connectAddress = new InetSocketAddress(url.getHost(), url.getPort());
|
||||
channel.connect(connectAddress);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("POST ").append(url.getRawPath()).append(" HTTP/1.1").append(HttpTunnelClientSocketPipelineSink.LINE_TERMINATOR).
|
||||
append("HOST: ").append(url.getHost()).append(":").append(url.getPort()).append(HttpTunnelClientSocketPipelineSink.LINE_TERMINATOR).
|
||||
append("Content-Type: application/octet-stream").append(HttpTunnelClientSocketPipelineSink.LINE_TERMINATOR).append("Transfer-Encoding: chunked").
|
||||
append(HttpTunnelClientSocketPipelineSink.LINE_TERMINATOR).append("Content-Transfer-Encoding: Binary").append(HttpTunnelClientSocketPipelineSink.LINE_TERMINATOR).append("Connection: Keep-Alive").
|
||||
append(HttpTunnelClientSocketPipelineSink.LINE_TERMINATOR);
|
||||
builder.append("POST ").append(url.getRawPath()).append(" HTTP/1.1").append(HttpTunnelingClientSocketPipelineSink.LINE_TERMINATOR).
|
||||
append("HOST: ").append(url.getHost()).append(":").append(url.getPort()).append(HttpTunnelingClientSocketPipelineSink.LINE_TERMINATOR).
|
||||
append("Content-Type: application/octet-stream").append(HttpTunnelingClientSocketPipelineSink.LINE_TERMINATOR).append("Transfer-Encoding: chunked").
|
||||
append(HttpTunnelingClientSocketPipelineSink.LINE_TERMINATOR).append("Content-Transfer-Encoding: Binary").append(HttpTunnelingClientSocketPipelineSink.LINE_TERMINATOR).append("Connection: Keep-Alive").
|
||||
append(HttpTunnelingClientSocketPipelineSink.LINE_TERMINATOR);
|
||||
if (reconnect) {
|
||||
builder.append("Cookie: JSESSIONID=").append(sessionId).append(HttpTunnelClientSocketPipelineSink.LINE_TERMINATOR);
|
||||
builder.append("Cookie: JSESSIONID=").append(sessionId).append(HttpTunnelingClientSocketPipelineSink.LINE_TERMINATOR);
|
||||
}
|
||||
builder.append(HttpTunnelClientSocketPipelineSink.LINE_TERMINATOR);
|
||||
builder.append(HttpTunnelingClientSocketPipelineSink.LINE_TERMINATOR);
|
||||
String msg = builder.toString();
|
||||
channel.write(ChannelBuffers.wrappedBuffer(msg.getBytes("ASCII7")));
|
||||
}
|
||||
|
||||
public void sendChunk(ChannelBuffer a) {
|
||||
int size = a.readableBytes();
|
||||
String hex = Integer.toHexString(size) + HttpTunnelClientSocketPipelineSink.LINE_TERMINATOR;
|
||||
String hex = Integer.toHexString(size) + HttpTunnelingClientSocketPipelineSink.LINE_TERMINATOR;
|
||||
|
||||
// try {
|
||||
synchronized (writeLock) {
|
||||
a.writeBytes(HttpTunnelClientSocketPipelineSink.LINE_TERMINATOR.getBytes());
|
||||
a.writeBytes(HttpTunnelingClientSocketPipelineSink.LINE_TERMINATOR.getBytes());
|
||||
channel.write(ChannelBuffers.wrappedBuffer(hex.getBytes()));
|
||||
channel.write(a).awaitUninterruptibly();
|
||||
//channel.write(ChannelBuffers.wrappedBuffer(LINE_TERMINATOR.getBytes()));
|
@ -35,7 +35,7 @@ import org.jboss.netty.util.ExecutorUtil;
|
||||
* @author Andy Taylor (andy.taylor@jboss.org)
|
||||
* @version $Rev$, $Date$
|
||||
*/
|
||||
public class HttpTunnelClientSocketChannelFactory implements ClientSocketChannelFactory {
|
||||
public class HttpTunnelingClientSocketChannelFactory implements ClientSocketChannelFactory {
|
||||
|
||||
private final Executor workerExecutor;
|
||||
private final ChannelSink sink;
|
||||
@ -45,7 +45,7 @@ public class HttpTunnelClientSocketChannelFactory implements ClientSocketChannel
|
||||
*
|
||||
* @param workerExecutor
|
||||
*/
|
||||
public HttpTunnelClientSocketChannelFactory(ClientSocketChannelFactory clientSocketChannelFactory, Executor workerExecutor) {
|
||||
public HttpTunnelingClientSocketChannelFactory(ClientSocketChannelFactory clientSocketChannelFactory, Executor workerExecutor) {
|
||||
this(workerExecutor, Runtime.getRuntime().availableProcessors());
|
||||
this.clientSocketChannelFactory = clientSocketChannelFactory;
|
||||
}
|
||||
@ -58,7 +58,7 @@ public class HttpTunnelClientSocketChannelFactory implements ClientSocketChannel
|
||||
* the {@link java.util.concurrent.Executor} which will execute the I/O worker threads
|
||||
* @param workerCount
|
||||
*/
|
||||
public HttpTunnelClientSocketChannelFactory(
|
||||
public HttpTunnelingClientSocketChannelFactory(
|
||||
Executor workerExecutor,
|
||||
int workerCount) {
|
||||
if (workerExecutor == null) {
|
||||
@ -71,11 +71,11 @@ public class HttpTunnelClientSocketChannelFactory implements ClientSocketChannel
|
||||
}
|
||||
|
||||
this.workerExecutor = workerExecutor;
|
||||
sink = new HttpTunnelClientSocketPipelineSink(workerExecutor);
|
||||
sink = new HttpTunnelingClientSocketPipelineSink(workerExecutor);
|
||||
}
|
||||
|
||||
public SocketChannel newChannel(ChannelPipeline pipeline) {
|
||||
return new HttpTunnelClientSocketChannel(this, pipeline, sink, clientSocketChannelFactory);
|
||||
return new HttpTunnelingClientSocketChannel(this, pipeline, sink, clientSocketChannelFactory);
|
||||
}
|
||||
|
||||
public void releaseExternalResources() {
|
@ -42,18 +42,18 @@ import org.jboss.netty.util.ThreadRenamingRunnable;
|
||||
* @author Andy Taylor (andy.taylor@jboss.org)
|
||||
* @version $Rev$, $Date$
|
||||
*/
|
||||
class HttpTunnelClientSocketPipelineSink extends AbstractChannelSink {
|
||||
class HttpTunnelingClientSocketPipelineSink extends AbstractChannelSink {
|
||||
|
||||
static String LINE_TERMINATOR = "\r\n";
|
||||
private final Executor workerExecutor;
|
||||
|
||||
HttpTunnelClientSocketPipelineSink(Executor workerExecutor) {
|
||||
HttpTunnelingClientSocketPipelineSink(Executor workerExecutor) {
|
||||
this.workerExecutor = workerExecutor;
|
||||
}
|
||||
|
||||
public void eventSunk(
|
||||
ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
||||
HttpTunnelClientSocketChannel channel = (HttpTunnelClientSocketChannel) e.getChannel();
|
||||
HttpTunnelingClientSocketChannel channel = (HttpTunnelingClientSocketChannel) e.getChannel();
|
||||
ChannelFuture future = e.getFuture();
|
||||
if (e instanceof ChannelStateEvent) {
|
||||
ChannelStateEvent stateEvent = (ChannelStateEvent) e;
|
||||
@ -91,7 +91,7 @@ class HttpTunnelClientSocketPipelineSink extends AbstractChannelSink {
|
||||
}
|
||||
|
||||
private void bind(
|
||||
HttpTunnelClientSocketChannel channel, ChannelFuture future,
|
||||
HttpTunnelingClientSocketChannel channel, ChannelFuture future,
|
||||
SocketAddress localAddress) {
|
||||
try {
|
||||
channel.bindSocket(localAddress);
|
||||
@ -104,7 +104,7 @@ class HttpTunnelClientSocketPipelineSink extends AbstractChannelSink {
|
||||
}
|
||||
|
||||
private void connect(
|
||||
HttpTunnelClientSocketChannel channel, ChannelFuture future,
|
||||
HttpTunnelingClientSocketChannel channel, ChannelFuture future,
|
||||
HttpTunnelAddress remoteAddress) {
|
||||
|
||||
boolean bound = channel.isBound();
|
@ -39,7 +39,7 @@ import org.jboss.netty.util.ConversionUtil;
|
||||
* @author Andy Taylor (andy.taylor@jboss.org)
|
||||
* @version $Rev$, $Date$
|
||||
*/
|
||||
public class HttpTunnelSocketChannelConfig implements SocketChannelConfig {
|
||||
public class HttpTunnelingSocketChannelConfig implements SocketChannelConfig {
|
||||
|
||||
final Socket socket;
|
||||
|
||||
@ -70,7 +70,7 @@ public class HttpTunnelSocketChannelConfig implements SocketChannelConfig {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*/
|
||||
public HttpTunnelSocketChannelConfig(Socket socket) {
|
||||
public HttpTunnelingSocketChannelConfig(Socket socket) {
|
||||
this.socket = socket;
|
||||
}
|
||||
|
||||
@ -315,8 +315,8 @@ public class HttpTunnelSocketChannelConfig implements SocketChannelConfig {
|
||||
// Unused
|
||||
}
|
||||
|
||||
HttpTunnelSocketChannelConfig copyConfig(Socket socket) {
|
||||
HttpTunnelSocketChannelConfig config = new HttpTunnelSocketChannelConfig(socket);
|
||||
HttpTunnelingSocketChannelConfig copyConfig(Socket socket) {
|
||||
HttpTunnelingSocketChannelConfig config = new HttpTunnelingSocketChannelConfig(socket);
|
||||
config.setConnectTimeoutMillis(connectTimeoutMillis);
|
||||
if (trafficClass != null) {
|
||||
config.setTrafficClass(trafficClass);
|
Loading…
Reference in New Issue
Block a user