Tabs to spaces

This commit is contained in:
Trustin Lee 2011-05-11 18:11:36 +09:00
parent 9db6bba913
commit 15792da167
8 changed files with 262 additions and 262 deletions

View File

@ -313,7 +313,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
* file to extract content type
*/
private void setContentTypeHeader(HttpResponse response, File file) {
MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
response.setHeader(HttpHeaders.Names.CONTENT_TYPE, mimeTypesMap.getContentType(file.getPath()));
}

View File

@ -128,17 +128,17 @@ public class HttpClient {
// Simple Get form: no factory used (not usable)
List<Entry<String,String>> headers =
formget(bootstrap, host, port, get, uriSimple);
formget(bootstrap, host, port, get, uriSimple);
if (headers == null) {
factory.cleanAllHttpDatas();
return;
factory.cleanAllHttpDatas();
return;
}
// Simple Post form: factory used for big attributes
List<InterfaceHttpData> bodylist =
formpost(bootstrap, host, port, uriSimple, file, factory, headers);
formpost(bootstrap, host, port, uriSimple, file, factory, headers);
if (bodylist == null) {
factory.cleanAllHttpDatas();
return;
factory.cleanAllHttpDatas();
return;
}
// Multipart Post form: factory used
formpostmultipart(bootstrap, host, port, uriFile, file, factory, headers, bodylist);
@ -155,7 +155,7 @@ public class HttpClient {
* @return the list of headers that will be used in every example after
**/
private static List<Entry<String,String>> formget(ClientBootstrap bootstrap, String host, int port, String get,
URI uriSimple) {
URI uriSimple) {
// XXX /formget
// No use of HttpPostRequestEncoder since not a POST
// Start the connection attempt.
@ -193,14 +193,14 @@ public class HttpClient {
request.setHeader(HttpHeaders.Names.HOST, host);
request.setHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE);
request.setHeader(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP+","+
HttpHeaders.Values.DEFLATE);
HttpHeaders.Values.DEFLATE);
request.setHeader(HttpHeaders.Names.ACCEPT_CHARSET, "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
request.setHeader(HttpHeaders.Names.ACCEPT_LANGUAGE, "fr");
request.setHeader(HttpHeaders.Names.REFERER, uriSimple.toString());
request.setHeader(HttpHeaders.Names.USER_AGENT, "Netty Simple Http Client side");
request.setHeader(HttpHeaders.Names.ACCEPT,
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
//connection will not close but needed
// request.setHeader("Connection","keep-alive");
// request.setHeader("Keep-Alive","300");
@ -232,12 +232,12 @@ public class HttpClient {
* @return the list of HttpData object (attribute and file) to be reused on next post
*/
private static List<InterfaceHttpData> formpost(ClientBootstrap bootstrap,
String host, int port,
URI uriSimple, File file, HttpDataFactory factory,
List<Entry<String,String>> headers) {
String host, int port,
URI uriSimple, File file, HttpDataFactory factory,
List<Entry<String,String>> headers) {
// XXX /formpost
// Start the connection attempt.
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
// Wait until the connection attempt succeeds or fails.
Channel channel = future.awaitUninterruptibly().getChannel();
if (!future.isSuccess()) {
@ -266,7 +266,7 @@ public class HttpClient {
// it is legal to add directly header or cookie into the request until finalize
for (Entry<String, String> entry : headers) {
request.setHeader(entry.getKey(), entry.getValue());
}
}
// add Form attribute
try {
@ -327,13 +327,13 @@ public class HttpClient {
* @param bodylist
*/
private static void formpostmultipart(ClientBootstrap bootstrap, String host, int port,
URI uriFile, File file, HttpDataFactory factory,
List<Entry<String,String>> headers, List<InterfaceHttpData> bodylist) {
URI uriFile, File file, HttpDataFactory factory,
List<Entry<String,String>> headers, List<InterfaceHttpData> bodylist) {
// XXX /formpostmultipart
// Start the connection attempt.
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
// Wait until the connection attempt succeeds or fails.
Channel channel = future.awaitUninterruptibly().getChannel();
Channel channel = future.awaitUninterruptibly().getChannel();
if (!future.isSuccess()) {
future.getCause().printStackTrace();
bootstrap.releaseExternalResources();

View File

@ -36,7 +36,7 @@ import org.jboss.netty.handler.stream.ChunkedWriteHandler;
* @version $Rev$, $Date$
*/
public class HttpClientPipelineFactory implements ChannelPipelineFactory {
private final boolean ssl;
private final boolean ssl;
public HttpClientPipelineFactory(boolean ssl) {
this.ssl = ssl;

View File

@ -36,7 +36,7 @@ public class HttpResponseHandler extends SimpleChannelUpstreamHandler {
private volatile boolean readingChunks;
@Override
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
if (!readingChunks) {
HttpResponse response = (HttpResponse) e.getMessage();

View File

@ -34,8 +34,8 @@ public class HttpServer {
// Configure the server.
ServerBootstrap bootstrap = new ServerBootstrap(
new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool()));
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool()));
// Set up the event pipeline factory.
bootstrap.setPipelineFactory(new HttpServerPipelineFactory());

View File

@ -51,7 +51,7 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
* Keep all HttpDatas until cleanAllHttpDatas() is called.
*/
private ConcurrentHashMap<HttpRequest, List<HttpData>> requestFileDeleteMap =
new ConcurrentHashMap<HttpRequest, List<HttpData>>();
new ConcurrentHashMap<HttpRequest, List<HttpData>>();
/**
* HttpData will be in memory if less than default size (16KB).
* The type will be Mixed.
@ -88,10 +88,10 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
* @return the associated list of Files for the request
*/
private List<HttpData> getList(HttpRequest request) {
List<HttpData> list = requestFileDeleteMap.get(request);
List<HttpData> list = requestFileDeleteMap.get(request);
if (list == null) {
list = new ArrayList<HttpData>();
requestFileDeleteMap.put(request, list);
list = new ArrayList<HttpData>();
requestFileDeleteMap.put(request, list);
}
return list;
}
@ -170,33 +170,33 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
@Override
public void removeHttpDataFromClean(HttpRequest request, InterfaceHttpData data) {
if (data instanceof HttpData) {
List<HttpData> fileToDelete = getList(request);
List<HttpData> fileToDelete = getList(request);
fileToDelete.remove(data);
}
}
@Override
public void cleanRequestHttpDatas(HttpRequest request) {
List<HttpData> fileToDelete = requestFileDeleteMap.remove(request);
if (fileToDelete != null) {
for (HttpData data: fileToDelete) {
data.delete();
}
fileToDelete.clear();
}
List<HttpData> fileToDelete = requestFileDeleteMap.remove(request);
if (fileToDelete != null) {
for (HttpData data: fileToDelete) {
data.delete();
}
fileToDelete.clear();
}
}
@Override
public void cleanAllHttpDatas() {
for (HttpRequest request : requestFileDeleteMap.keySet()) {
List<HttpData> fileToDelete = requestFileDeleteMap.get(request);
if (fileToDelete != null) {
for (HttpData data: fileToDelete) {
data.delete();
}
fileToDelete.clear();
}
requestFileDeleteMap.remove(request);
}
for (HttpRequest request : requestFileDeleteMap.keySet()) {
List<HttpData> fileToDelete = requestFileDeleteMap.get(request);
if (fileToDelete != null) {
for (HttpData data: fileToDelete) {
data.delete();
}
fileToDelete.clear();
}
requestFileDeleteMap.remove(request);
}
}
}

View File

@ -634,7 +634,7 @@ public class HttpPostRequestDecoder {
}
case FIELD: {
// Now get value according to Content-Type and Charset
Charset localCharset = null;
Charset localCharset = null;
Attribute charsetAttribute = currentFieldAttributes
.get(HttpHeaders.Values.CHARSET);
if (charsetAttribute != null) {
@ -854,7 +854,7 @@ public class HttpPostRequestDecoder {
Attribute attribute;
try {
attribute = factory.createAttribute(request,
contents[0].trim(),
contents[0].trim(),
decodeAttribute(cleanString(contents[i]), charset));
} catch (NullPointerException e) {
throw new ErrorDataDecoderException(e);

View File

@ -19,260 +19,260 @@ import org.junit.Test;
public class IpFilterRuleTest extends TestCase
{
public static boolean accept(IpFilterRuleHandler h, InetSocketAddress addr) throws Exception
{
return h.accept(new ChannelHandlerContext()
public static boolean accept(IpFilterRuleHandler h, InetSocketAddress addr) throws Exception
{
return h.accept(new ChannelHandlerContext()
{
@Override
public boolean canHandleDownstream()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean canHandleDownstream()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean canHandleUpstream()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean canHandleUpstream()
{
// TODO Auto-generated method stub
return false;
}
@Override
public Object getAttachment()
{
// TODO Auto-generated method stub
return null;
}
@Override
public Object getAttachment()
{
// TODO Auto-generated method stub
return null;
}
@Override
public Channel getChannel()
{
// TODO Auto-generated method stub
return null;
}
@Override
public Channel getChannel()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelHandler getHandler()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelHandler getHandler()
{
// TODO Auto-generated method stub
return null;
}
@Override
public String getName()
{
// TODO Auto-generated method stub
return null;
}
@Override
public String getName()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelPipeline getPipeline()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelPipeline getPipeline()
{
// TODO Auto-generated method stub
return null;
}
@Override
public void sendDownstream(ChannelEvent e)
{
// TODO Auto-generated method stub
}
@Override
public void sendDownstream(ChannelEvent e)
{
// TODO Auto-generated method stub
}
@Override
public void sendUpstream(ChannelEvent e)
{
// TODO Auto-generated method stub
}
@Override
public void sendUpstream(ChannelEvent e)
{
// TODO Auto-generated method stub
}
@Override
public void setAttachment(Object attachment)
{
// TODO Auto-generated method stub
}
@Override
public void setAttachment(Object attachment)
{
// TODO Auto-generated method stub
}
},
new UpstreamMessageEvent(new Channel()
{
@Override
public ChannelFuture bind(SocketAddress localAddress)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture bind(SocketAddress localAddress)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture close()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture close()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture connect(SocketAddress remoteAddress)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture connect(SocketAddress remoteAddress)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture disconnect()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture disconnect()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture getCloseFuture()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture getCloseFuture()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelConfig getConfig()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelConfig getConfig()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFactory getFactory()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFactory getFactory()
{
// TODO Auto-generated method stub
return null;
}
@Override
public Integer getId()
{
// TODO Auto-generated method stub
return null;
}
@Override
public Integer getId()
{
// TODO Auto-generated method stub
return null;
}
@Override
public int getInterestOps()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public int getInterestOps()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public SocketAddress getLocalAddress()
{
// TODO Auto-generated method stub
return null;
}
@Override
public SocketAddress getLocalAddress()
{
// TODO Auto-generated method stub
return null;
}
@Override
public Channel getParent()
{
// TODO Auto-generated method stub
return null;
}
@Override
public Channel getParent()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelPipeline getPipeline()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelPipeline getPipeline()
{
// TODO Auto-generated method stub
return null;
}
@Override
public SocketAddress getRemoteAddress()
{
// TODO Auto-generated method stub
return null;
}
@Override
public SocketAddress getRemoteAddress()
{
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isBound()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isBound()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isConnected()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isConnected()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isOpen()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isOpen()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isReadable()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isReadable()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isWritable()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isWritable()
{
// TODO Auto-generated method stub
return false;
}
@Override
public ChannelFuture setInterestOps(int interestOps)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture setInterestOps(int interestOps)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture setReadable(boolean readable)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture setReadable(boolean readable)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture unbind()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture unbind()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture write(Object message)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture write(Object message)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture write(Object message, SocketAddress remoteAddress)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ChannelFuture write(Object message, SocketAddress remoteAddress)
{
// TODO Auto-generated method stub
return null;
}
@Override
public int compareTo(Channel o)
{
// TODO Auto-generated method stub
return 0;
}
@Override
public int compareTo(Channel o)
{
// TODO Auto-generated method stub
return 0;
}
}, h, addr),
addr);
}
@Test
public void testIpFilterRule() throws Exception
{
}
@Test
public void testIpFilterRule() throws Exception
{
IpFilterRuleHandler h = new IpFilterRuleHandler();
h.addAll(new IpFilterRuleList("+n:localhost, -n:*"));
InetSocketAddress addr = new InetSocketAddress(InetAddress.getLocalHost(), 8080);
@ -317,6 +317,6 @@ public class IpFilterRuleTest extends TestCase
addr = new InetSocketAddress(InetAddress.getByName(InetAddress.getLocalHost().getHostName()), 8080);
assertTrue(accept(h, addr));
}
}
}