Rename HTTP snoop example classes for disambiguation

This commit is contained in:
Trustin Lee 2012-01-15 00:28:25 +09:00
parent 1b02743367
commit b7cfc6b7f0
7 changed files with 19 additions and 19 deletions

View File

@ -32,13 +32,13 @@ import io.netty.handler.codec.http.HttpVersion;
/**
* A simple HTTP client that prints out the content of the HTTP response to
* {@link System#out} to test {@link HttpServer}.
* {@link System#out} to test {@link HttpSnoopServer}.
*/
public class HttpClient {
public class HttpSnoopClient {
private final URI uri;
public HttpClient(URI uri) {
public HttpSnoopClient(URI uri) {
this.uri = uri;
}
@ -68,7 +68,7 @@ public class HttpClient {
Executors.newCachedThreadPool()));
// Set up the event pipeline factory.
bootstrap.setPipelineFactory(new HttpClientPipelineFactory(ssl));
bootstrap.setPipelineFactory(new HttpSnoopClientPipelineFactory(ssl));
// Start the connection attempt.
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
@ -107,12 +107,12 @@ public class HttpClient {
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println(
"Usage: " + HttpClient.class.getSimpleName() +
"Usage: " + HttpSnoopClient.class.getSimpleName() +
" <URL>");
return;
}
URI uri = new URI(args[0]);
new HttpClient(uri).run();
new HttpSnoopClient(uri).run();
}
}

View File

@ -23,7 +23,7 @@ import io.netty.handler.codec.http.HttpChunk;
import io.netty.handler.codec.http.HttpResponse;
import io.netty.util.CharsetUtil;
public class HttpResponseHandler extends SimpleChannelUpstreamHandler {
public class HttpSnoopClientHandler extends SimpleChannelUpstreamHandler {
private boolean readingChunks;

View File

@ -28,11 +28,11 @@ import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.ssl.SslHandler;
import io.netty.logging.InternalLogLevel;
public class HttpClientPipelineFactory implements ChannelPipelineFactory {
public class HttpSnoopClientPipelineFactory implements ChannelPipelineFactory {
private final boolean ssl;
public HttpClientPipelineFactory(boolean ssl) {
public HttpSnoopClientPipelineFactory(boolean ssl) {
this.ssl = ssl;
}
@ -59,7 +59,7 @@ public class HttpClientPipelineFactory implements ChannelPipelineFactory {
// Uncomment the following line if you don't want to handle HttpChunks.
//pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
pipeline.addLast("handler", new HttpResponseHandler());
pipeline.addLast("handler", new HttpSnoopClientHandler());
return pipeline;
}
}

View File

@ -25,11 +25,11 @@ import io.netty.channel.socket.nio.NioServerSocketChannelFactory;
* An HTTP server that sends back the content of the received HTTP request
* in a pretty plaintext form.
*/
public class HttpServer {
public class HttpSnoopServer {
private final int port;
public HttpServer(int port) {
public HttpSnoopServer(int port) {
this.port = port;
}
@ -41,7 +41,7 @@ public class HttpServer {
Executors.newCachedThreadPool()));
// Set up the event pipeline factory.
bootstrap.setPipelineFactory(new HttpServerPipelineFactory());
bootstrap.setPipelineFactory(new HttpSnoopServerPipelineFactory());
// Bind and start to accept incoming connections.
bootstrap.bind(new InetSocketAddress(port));
@ -54,6 +54,6 @@ public class HttpServer {
} else {
port = 8080;
}
new HttpServer(port).run();
new HttpSnoopServer(port).run();
}
}

View File

@ -44,7 +44,7 @@ import io.netty.handler.codec.http.HttpResponse;
import io.netty.handler.codec.http.QueryStringDecoder;
import io.netty.util.CharsetUtil;
public class HttpRequestHandler extends SimpleChannelUpstreamHandler {
public class HttpSnoopServerHandler extends SimpleChannelUpstreamHandler {
private HttpRequest request;
private boolean readingChunks;

View File

@ -25,7 +25,7 @@ import io.netty.handler.codec.http.HttpResponseEncoder;
import io.netty.handler.logging.LoggingHandler;
import io.netty.logging.InternalLogLevel;
public class HttpServerPipelineFactory implements ChannelPipelineFactory {
public class HttpSnoopServerPipelineFactory implements ChannelPipelineFactory {
@Override
public ChannelPipeline getPipeline() throws Exception {
// Create a default pipeline implementation.
@ -43,7 +43,7 @@ public class HttpServerPipelineFactory implements ChannelPipelineFactory {
pipeline.addLast("encoder", new HttpResponseEncoder());
// Remove the following line if you don't want automatic content compression.
pipeline.addLast("deflater", new HttpContentCompressor());
pipeline.addLast("handler", new HttpRequestHandler());
pipeline.addLast("handler", new HttpSnoopServerHandler());
return pipeline;
}
}

View File

@ -24,7 +24,7 @@ import io.netty.channel.ChannelPipeline;
import io.netty.example.factorial.BigIntegerDecoder;
import io.netty.example.factorial.FactorialServerHandler;
import io.netty.example.factorial.NumberEncoder;
import io.netty.example.http.snoop.HttpRequestHandler;
import io.netty.example.http.snoop.HttpSnoopServerHandler;
import io.netty.example.securechat.SecureChatSslContextFactory;
import io.netty.handler.codec.compression.ZlibDecoder;
import io.netty.handler.codec.compression.ZlibEncoder;
@ -144,7 +144,7 @@ public class PortUnificationServerHandler extends FrameDecoder {
p.addLast("decoder", new HttpRequestDecoder());
p.addLast("encoder", new HttpResponseEncoder());
p.addLast("deflater", new HttpContentCompressor());
p.addLast("handler", new HttpRequestHandler());
p.addLast("handler", new HttpSnoopServerHandler());
p.remove(this);
}