Merge branch '3' of ssh://github.com/netty/netty into 3
This commit is contained in:
commit
9d9f96bb5e
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.channel.socket;
|
||||
|
||||
/**
|
||||
* Internet Protocol (IP) families
|
||||
*/
|
||||
public enum InternetProtocolFamily {
|
||||
IPv4,
|
||||
IPv6;
|
||||
}
|
@ -17,18 +17,6 @@ package org.jboss.netty.channel.socket.nio;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.socket.Worker;
|
||||
import org.jboss.netty.channel.socket.nio.SocketSendBufferPool.SendBuffer;
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
import org.jboss.netty.util.ThreadRenamingRunnable;
|
||||
import org.jboss.netty.util.internal.DeadLockProofWorker;
|
||||
import org.jboss.netty.util.internal.QueueFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.AsynchronousCloseException;
|
||||
import java.nio.channels.CancelledKeyException;
|
||||
@ -47,6 +35,18 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.socket.Worker;
|
||||
import org.jboss.netty.channel.socket.nio.SocketSendBufferPool.SendBuffer;
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
import org.jboss.netty.util.ThreadRenamingRunnable;
|
||||
import org.jboss.netty.util.internal.DeadLockProofWorker;
|
||||
import org.jboss.netty.util.internal.QueueFactory;
|
||||
|
||||
abstract class AbstractNioWorker implements Worker {
|
||||
|
||||
|
||||
@ -157,7 +157,7 @@ abstract class AbstractNioWorker implements Worker {
|
||||
if (!started) {
|
||||
// Open a selector if this worker didn't start yet.
|
||||
try {
|
||||
this.selector = Selector.open();
|
||||
selector = Selector.open();
|
||||
} catch (Throwable t) {
|
||||
throw new ChannelException("Failed to create a selector.", t);
|
||||
}
|
||||
@ -175,7 +175,7 @@ abstract class AbstractNioWorker implements Worker {
|
||||
} catch (Throwable t) {
|
||||
logger.warn("Failed to close a selector.", t);
|
||||
}
|
||||
this.selector = null;
|
||||
selector = null;
|
||||
// The method will return to the caller at this point.
|
||||
}
|
||||
}
|
||||
|
@ -16,14 +16,14 @@
|
||||
|
||||
package org.jboss.netty.channel.socket.nio;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.socket.Worker;
|
||||
import org.jboss.netty.util.ExternalResourceReleasable;
|
||||
import org.jboss.netty.util.internal.ExecutorUtil;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Abstract base class for {@link WorkerPool} implementations that create the {@link Worker}'s up-front and return them in a "fair" fashion when calling
|
||||
* {@link #nextWorker()}
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.jboss.netty.channel.socket.nio;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.fireChannelOpen;
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
||||
import java.nio.channels.SocketChannel;
|
||||
|
||||
|
@ -38,6 +38,7 @@ import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelSink;
|
||||
import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.socket.DatagramChannelConfig;
|
||||
import org.jboss.netty.channel.socket.InternetProtocolFamily;
|
||||
import org.jboss.netty.util.internal.DetectionUtil;
|
||||
|
||||
/**
|
||||
@ -46,34 +47,15 @@ import org.jboss.netty.util.internal.DetectionUtil;
|
||||
public final class NioDatagramChannel extends AbstractNioChannel<DatagramChannel>
|
||||
implements org.jboss.netty.channel.socket.DatagramChannel {
|
||||
|
||||
/**
|
||||
* The supported ProtocolFamily by UDP
|
||||
*
|
||||
*/
|
||||
public enum ProtocolFamily {
|
||||
INET,
|
||||
INET6
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link DatagramChannelConfig}.
|
||||
*/
|
||||
private final NioDatagramChannelConfig config;
|
||||
private Map<InetAddress, List<MembershipKey>> memberships;
|
||||
|
||||
/**
|
||||
* Use {@link #NioDatagramChannel(ChannelFactory, ChannelPipeline, ChannelSink, NioDatagramWorker, ProtocolFamily)}
|
||||
*/
|
||||
@Deprecated
|
||||
NioDatagramChannel(final ChannelFactory factory,
|
||||
final ChannelPipeline pipeline, final ChannelSink sink,
|
||||
final NioDatagramWorker worker) {
|
||||
this(factory, pipeline, sink, worker, null);
|
||||
}
|
||||
|
||||
NioDatagramChannel(final ChannelFactory factory,
|
||||
final ChannelPipeline pipeline, final ChannelSink sink,
|
||||
final NioDatagramWorker worker, ProtocolFamily family) {
|
||||
final NioDatagramWorker worker, InternetProtocolFamily family) {
|
||||
super(null, factory, pipeline, sink, worker, openNonBlockingChannel(family));
|
||||
config = new DefaultNioDatagramChannelConfig(channel);
|
||||
|
||||
@ -81,7 +63,7 @@ public final class NioDatagramChannel extends AbstractNioChannel<DatagramChannel
|
||||
|
||||
}
|
||||
|
||||
private static DatagramChannel openNonBlockingChannel(ProtocolFamily family) {
|
||||
private static DatagramChannel openNonBlockingChannel(InternetProtocolFamily family) {
|
||||
try {
|
||||
final DatagramChannel channel;
|
||||
|
||||
@ -95,11 +77,11 @@ public final class NioDatagramChannel extends AbstractNioChannel<DatagramChannel
|
||||
//
|
||||
// See #368
|
||||
switch (family) {
|
||||
case INET:
|
||||
case IPv4:
|
||||
channel = DatagramChannel.open(ProtocolFamilyConverter.convert(family));
|
||||
break;
|
||||
|
||||
case INET6:
|
||||
case IPv6:
|
||||
channel = DatagramChannel.open(ProtocolFamilyConverter.convert(family));
|
||||
break;
|
||||
|
||||
|
@ -24,8 +24,8 @@ import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.group.ChannelGroup;
|
||||
import org.jboss.netty.channel.socket.DatagramChannel;
|
||||
import org.jboss.netty.channel.socket.DatagramChannelFactory;
|
||||
import org.jboss.netty.channel.socket.InternetProtocolFamily;
|
||||
import org.jboss.netty.channel.socket.Worker;
|
||||
import org.jboss.netty.channel.socket.nio.NioDatagramChannel.ProtocolFamily;
|
||||
import org.jboss.netty.channel.socket.oio.OioDatagramChannelFactory;
|
||||
import org.jboss.netty.util.ExternalResourceReleasable;
|
||||
|
||||
@ -80,14 +80,16 @@ public class NioDatagramChannelFactory implements DatagramChannelFactory {
|
||||
|
||||
private final NioDatagramPipelineSink sink;
|
||||
private final WorkerPool<NioDatagramWorker> workerPool;
|
||||
private final NioDatagramChannel.ProtocolFamily family;
|
||||
private final InternetProtocolFamily family;
|
||||
|
||||
/**
|
||||
* Create a new {@link NioDatagramChannelFactory} with a {@link Executors#newCachedThreadPool()}.
|
||||
* Create a new {@link NioDatagramChannelFactory} with a {@link Executors#newCachedThreadPool()}
|
||||
* and without preferred {@link InternetProtocolFamily}. Please note that the {@link InternetProtocolFamily}
|
||||
* of the channel will be platform (and possibly configuration) dependent and therefore
|
||||
* unspecified. Use {@link #NioDatagramChannelFactory(InternetProtocolFamily)} if unsure.
|
||||
*
|
||||
* See {@link #NioDatagramChannelFactory(Executor)}
|
||||
*/
|
||||
@Deprecated
|
||||
public NioDatagramChannelFactory() {
|
||||
this(Executors.newCachedThreadPool(), null);
|
||||
}
|
||||
@ -97,7 +99,7 @@ public class NioDatagramChannelFactory implements DatagramChannelFactory {
|
||||
*
|
||||
* See {@link #NioDatagramChannelFactory(Executor)}
|
||||
*/
|
||||
public NioDatagramChannelFactory(ProtocolFamily family) {
|
||||
public NioDatagramChannelFactory(InternetProtocolFamily family) {
|
||||
this(Executors.newCachedThreadPool(), family);
|
||||
}
|
||||
|
||||
@ -106,35 +108,44 @@ public class NioDatagramChannelFactory implements DatagramChannelFactory {
|
||||
* {@link #NioDatagramChannelFactory(Executor, int)} with 2 * the number of
|
||||
* available processors in the machine. The number of available processors
|
||||
* is obtained by {@link Runtime#availableProcessors()}.
|
||||
* <p>
|
||||
* Please note that the {@link InternetProtocolFamily} of the channel will be platform (and possibly
|
||||
* configuration) dependent and therefore unspecified.
|
||||
* Use {@link #NioDatagramChannelFactory(Executor, InternetProtocolFamily)} if unsure.
|
||||
*
|
||||
* @param workerExecutor
|
||||
* the {@link Executor} which will execute the I/O worker threads
|
||||
*/
|
||||
@Deprecated
|
||||
public NioDatagramChannelFactory(final Executor workerExecutor) {
|
||||
this(workerExecutor, SelectorUtil.DEFAULT_IO_THREADS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* <p>
|
||||
* Please note that the {@link InternetProtocolFamily} of the channel will be platform (and possibly
|
||||
* configuration) dependent and therefore unspecified.
|
||||
* Use {@link #NioDatagramChannelFactory(Executor, int, InternetProtocolFamily)} if unsure.
|
||||
*
|
||||
* @param workerExecutor
|
||||
* the {@link Executor} which will execute the I/O worker threads
|
||||
* @param workerCount
|
||||
* the maximum number of I/O worker threads
|
||||
*/
|
||||
@Deprecated
|
||||
public NioDatagramChannelFactory(final Executor workerExecutor, final int workerCount) {
|
||||
this(new NioDatagramWorkerPool(workerExecutor, workerCount, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* <p>
|
||||
* Please note that the {@link InternetProtocolFamily} of the channel will be platform (and possibly
|
||||
* configuration) dependent and therefore unspecified.
|
||||
* Use {@link #NioDatagramChannelFactory(WorkerPool, InternetProtocolFamily)} if unsure.
|
||||
*
|
||||
* @param workerPool
|
||||
* the {@link WorkerPool} which will be used to obtain the {@link NioDatagramWorker} that execute the I/O worker threads
|
||||
*/
|
||||
@Deprecated
|
||||
public NioDatagramChannelFactory(WorkerPool<NioDatagramWorker> workerPool) {
|
||||
this(workerPool, null);
|
||||
}
|
||||
@ -148,10 +159,10 @@ public class NioDatagramChannelFactory implements DatagramChannelFactory {
|
||||
* @param workerExecutor
|
||||
* the {@link Executor} which will execute the I/O worker threads
|
||||
* @param family
|
||||
* the {@link ProtocolFamily} to use. This should be used for UDP multicast.
|
||||
* the {@link InternetProtocolFamily} to use. This should be used for UDP multicast.
|
||||
* <strong>Be aware that this option is only considered when running on java7+</strong>
|
||||
*/
|
||||
public NioDatagramChannelFactory(final Executor workerExecutor, ProtocolFamily family) {
|
||||
public NioDatagramChannelFactory(final Executor workerExecutor, InternetProtocolFamily family) {
|
||||
this(workerExecutor, SelectorUtil.DEFAULT_IO_THREADS, family);
|
||||
}
|
||||
|
||||
@ -163,11 +174,11 @@ public class NioDatagramChannelFactory implements DatagramChannelFactory {
|
||||
* @param workerCount
|
||||
* the maximum number of I/O worker threads
|
||||
* @param family
|
||||
* the {@link ProtocolFamily} to use. This should be used for UDP multicast.
|
||||
* the {@link InternetProtocolFamily} to use. This should be used for UDP multicast.
|
||||
* <strong>Be aware that this option is only considered when running on java7+</strong>
|
||||
*/
|
||||
public NioDatagramChannelFactory(final Executor workerExecutor,
|
||||
final int workerCount, ProtocolFamily family) {
|
||||
final int workerCount, InternetProtocolFamily family) {
|
||||
this(new NioDatagramWorkerPool(workerExecutor, workerCount, true), family);
|
||||
}
|
||||
|
||||
@ -177,10 +188,10 @@ public class NioDatagramChannelFactory implements DatagramChannelFactory {
|
||||
* @param workerPool
|
||||
* the {@link WorkerPool} which will be used to obtain the {@link Worker} that execute the I/O worker threads
|
||||
* @param family
|
||||
* the {@link ProtocolFamily} to use. This should be used for UDP multicast.
|
||||
* the {@link InternetProtocolFamily} to use. This should be used for UDP multicast.
|
||||
* <strong>Be aware that this option is only considered when running on java7+</strong>
|
||||
*/
|
||||
public NioDatagramChannelFactory(WorkerPool<NioDatagramWorker> workerPool, ProtocolFamily family) {
|
||||
public NioDatagramChannelFactory(WorkerPool<NioDatagramWorker> workerPool, InternetProtocolFamily family) {
|
||||
this.workerPool = workerPool;
|
||||
this.family = family;
|
||||
sink = new NioDatagramPipelineSink(workerPool);
|
||||
|
@ -15,18 +15,7 @@
|
||||
*/
|
||||
package org.jboss.netty.channel.socket.nio;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.fireChannelDisconnected;
|
||||
import static org.jboss.netty.channel.Channels.fireChannelDisconnectedLater;
|
||||
import static org.jboss.netty.channel.Channels.fireExceptionCaught;
|
||||
import static org.jboss.netty.channel.Channels.fireExceptionCaughtLater;
|
||||
import static org.jboss.netty.channel.Channels.fireMessageReceived;
|
||||
import static org.jboss.netty.channel.Channels.succeededFuture;
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.ReceiveBufferSizePredictor;
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.SocketAddress;
|
||||
@ -39,6 +28,13 @@ import java.nio.channels.Selector;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.ReceiveBufferSizePredictor;
|
||||
|
||||
/**
|
||||
* A class responsible for registering channels with {@link Selector}.
|
||||
* It also implements the {@link Selector} loop.
|
||||
|
@ -15,16 +15,7 @@
|
||||
*/
|
||||
package org.jboss.netty.channel.socket.nio;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.fireChannelBound;
|
||||
import static org.jboss.netty.channel.Channels.fireChannelConnected;
|
||||
import static org.jboss.netty.channel.Channels.fireExceptionCaught;
|
||||
import static org.jboss.netty.channel.Channels.fireMessageReceived;
|
||||
import static org.jboss.netty.channel.Channels.succeededFuture;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ReceiveBufferSizePredictor;
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.SocketAddress;
|
||||
@ -35,6 +26,12 @@ import java.nio.channels.Selector;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.channel.ChannelException;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ReceiveBufferSizePredictor;
|
||||
|
||||
public class NioWorker extends AbstractNioWorker {
|
||||
|
||||
private final SocketReceiveBufferPool recvBufferPool = new SocketReceiveBufferPool();
|
||||
|
@ -15,11 +15,12 @@
|
||||
*/
|
||||
package org.jboss.netty.channel.socket.nio;
|
||||
|
||||
import java.net.ProtocolFamily;
|
||||
import org.jboss.netty.channel.socket.InternetProtocolFamily;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Helper class which convert the {@link ProtocolFamily}.
|
||||
* Helper class which convert the {@link InternetProtocolFamily}.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ -30,14 +31,14 @@ final class ProtocolFamilyConverter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the {@link NioDatagramChannel.ProtocolFamily}. This MUST only be called on jdk version >= 7.
|
||||
* Convert the {@link InternetProtocolFamily}. This MUST only be called on jdk version >= 7.
|
||||
*/
|
||||
public static ProtocolFamily convert(NioDatagramChannel.ProtocolFamily family) {
|
||||
public static java.net.ProtocolFamily convert(InternetProtocolFamily family) {
|
||||
switch (family) {
|
||||
case INET:
|
||||
case IPv4:
|
||||
return java.net.StandardProtocolFamily.INET;
|
||||
|
||||
case INET6:
|
||||
case IPv6:
|
||||
return java.net.StandardProtocolFamily.INET6;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
|
@ -267,7 +267,7 @@ final class SocketSendBufferPool {
|
||||
|
||||
GatheringSendBuffer(ByteBuffer[] buffers) {
|
||||
this.buffers = buffers;
|
||||
this.last = buffers.length - 1;
|
||||
last = buffers.length - 1;
|
||||
int total = 0;
|
||||
for (ByteBuffer buf: buffers) {
|
||||
total += buf.remaining();
|
||||
|
@ -16,15 +16,16 @@
|
||||
package org.jboss.netty.channel.socket.oio;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Queue;
|
||||
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.socket.Worker;
|
||||
import org.jboss.netty.util.internal.QueueFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Queue;
|
||||
|
||||
/**
|
||||
* Abstract base class for Oio-Worker implementations
|
||||
*
|
||||
|
@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.jboss.netty.channel.socket.oio;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.fireChannelBound;
|
||||
import static org.jboss.netty.channel.Channels.fireChannelOpen;
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
@ -28,19 +28,19 @@ import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
|
||||
import org.jboss.netty.handler.codec.http.CookieEncoder;
|
||||
import org.jboss.netty.handler.codec.http.DefaultHttpDataFactory;
|
||||
import org.jboss.netty.handler.codec.http.DefaultHttpRequest;
|
||||
import org.jboss.netty.handler.codec.http.DiskAttribute;
|
||||
import org.jboss.netty.handler.codec.http.DiskFileUpload;
|
||||
import org.jboss.netty.handler.codec.http.HttpDataFactory;
|
||||
import org.jboss.netty.handler.codec.http.HttpHeaders;
|
||||
import org.jboss.netty.handler.codec.http.HttpMethod;
|
||||
import org.jboss.netty.handler.codec.http.HttpPostRequestEncoder;
|
||||
import org.jboss.netty.handler.codec.http.HttpPostRequestEncoder.ErrorDataEncoderException;
|
||||
import org.jboss.netty.handler.codec.http.HttpRequest;
|
||||
import org.jboss.netty.handler.codec.http.HttpVersion;
|
||||
import org.jboss.netty.handler.codec.http.InterfaceHttpData;
|
||||
import org.jboss.netty.handler.codec.http.QueryStringEncoder;
|
||||
import org.jboss.netty.handler.codec.http.multipart.DefaultHttpDataFactory;
|
||||
import org.jboss.netty.handler.codec.http.multipart.DiskAttribute;
|
||||
import org.jboss.netty.handler.codec.http.multipart.DiskFileUpload;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpDataFactory;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestEncoder;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestEncoder.ErrorDataEncoderException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.InterfaceHttpData;
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
|
||||
|
@ -34,30 +34,30 @@ import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.ExceptionEvent;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
||||
import org.jboss.netty.handler.codec.http.Attribute;
|
||||
import org.jboss.netty.handler.codec.http.Cookie;
|
||||
import org.jboss.netty.handler.codec.http.CookieDecoder;
|
||||
import org.jboss.netty.handler.codec.http.CookieEncoder;
|
||||
import org.jboss.netty.handler.codec.http.DefaultHttpDataFactory;
|
||||
import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
|
||||
import org.jboss.netty.handler.codec.http.DiskAttribute;
|
||||
import org.jboss.netty.handler.codec.http.DiskFileUpload;
|
||||
import org.jboss.netty.handler.codec.http.FileUpload;
|
||||
import org.jboss.netty.handler.codec.http.HttpChunk;
|
||||
import org.jboss.netty.handler.codec.http.HttpDataFactory;
|
||||
import org.jboss.netty.handler.codec.http.HttpHeaders;
|
||||
import org.jboss.netty.handler.codec.http.HttpPostRequestDecoder;
|
||||
import org.jboss.netty.handler.codec.http.HttpPostRequestDecoder.EndOfDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.HttpPostRequestDecoder.ErrorDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.HttpPostRequestDecoder.IncompatibleDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.HttpPostRequestDecoder.NotEnoughDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.HttpRequest;
|
||||
import org.jboss.netty.handler.codec.http.HttpResponse;
|
||||
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
|
||||
import org.jboss.netty.handler.codec.http.HttpVersion;
|
||||
import org.jboss.netty.handler.codec.http.InterfaceHttpData;
|
||||
import org.jboss.netty.handler.codec.http.InterfaceHttpData.HttpDataType;
|
||||
import org.jboss.netty.handler.codec.http.QueryStringDecoder;
|
||||
import org.jboss.netty.handler.codec.http.multipart.Attribute;
|
||||
import org.jboss.netty.handler.codec.http.multipart.DefaultHttpDataFactory;
|
||||
import org.jboss.netty.handler.codec.http.multipart.DiskAttribute;
|
||||
import org.jboss.netty.handler.codec.http.multipart.DiskFileUpload;
|
||||
import org.jboss.netty.handler.codec.http.multipart.FileUpload;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpDataFactory;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.EndOfDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.IncompatibleDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder.NotEnoughDataDecoderException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.InterfaceHttpData;
|
||||
import org.jboss.netty.handler.codec.http.multipart.InterfaceHttpData.HttpDataType;
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
import org.jboss.netty.util.CharsetUtil;
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.jboss.netty.example.http.upload;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.pipeline;
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelPipelineFactory;
|
||||
|
@ -249,7 +249,7 @@ public final class LocalTimeProtocol {
|
||||
public static final int CONTINENT_FIELD_NUMBER = 1;
|
||||
private org.jboss.netty.example.localtime.LocalTimeProtocol.Continent continent_;
|
||||
public boolean hasContinent() {
|
||||
return ((bitField0_ & 0x00000001) == 0x00000001);
|
||||
return (bitField0_ & 0x00000001) == 0x00000001;
|
||||
}
|
||||
public org.jboss.netty.example.localtime.LocalTimeProtocol.Continent getContinent() {
|
||||
return continent_;
|
||||
@ -259,7 +259,7 @@ public final class LocalTimeProtocol {
|
||||
public static final int CITY_FIELD_NUMBER = 2;
|
||||
private java.lang.Object city_;
|
||||
public boolean hasCity() {
|
||||
return ((bitField0_ & 0x00000002) == 0x00000002);
|
||||
return (bitField0_ & 0x00000002) == 0x00000002;
|
||||
}
|
||||
public String getCity() {
|
||||
java.lang.Object ref = city_;
|
||||
@ -294,7 +294,9 @@ public final class LocalTimeProtocol {
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized != -1) return isInitialized == 1;
|
||||
if (isInitialized != -1) {
|
||||
return isInitialized == 1;
|
||||
}
|
||||
|
||||
if (!hasContinent()) {
|
||||
memoizedIsInitialized = 0;
|
||||
@ -311,10 +313,10 @@ public final class LocalTimeProtocol {
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
getSerializedSize();
|
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
if ((bitField0_ & 0x00000001) == 0x00000001) {
|
||||
output.writeEnum(1, continent_.getNumber());
|
||||
}
|
||||
if (((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
if ((bitField0_ & 0x00000002) == 0x00000002) {
|
||||
output.writeBytes(2, getCityBytes());
|
||||
}
|
||||
getUnknownFields().writeTo(output);
|
||||
@ -323,14 +325,16 @@ public final class LocalTimeProtocol {
|
||||
private int memoizedSerializedSize = -1;
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSerializedSize;
|
||||
if (size != -1) return size;
|
||||
if (size != -1) {
|
||||
return size;
|
||||
}
|
||||
|
||||
size = 0;
|
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
if ((bitField0_ & 0x00000001) == 0x00000001) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeEnumSize(1, continent_.getNumber());
|
||||
}
|
||||
if (((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
if ((bitField0_ & 0x00000002) == 0x00000002) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeBytesSize(2, getCityBytes());
|
||||
}
|
||||
@ -459,9 +463,9 @@ public final class LocalTimeProtocol {
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
continent_ = org.jboss.netty.example.localtime.LocalTimeProtocol.Continent.AFRICA;
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
bitField0_ = bitField0_ & ~0x00000001;
|
||||
city_ = "";
|
||||
bitField0_ = (bitField0_ & ~0x00000002);
|
||||
bitField0_ = bitField0_ & ~0x00000002;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -500,11 +504,11 @@ public final class LocalTimeProtocol {
|
||||
org.jboss.netty.example.localtime.LocalTimeProtocol.Location result = new org.jboss.netty.example.localtime.LocalTimeProtocol.Location(this);
|
||||
int from_bitField0_ = bitField0_;
|
||||
int to_bitField0_ = 0;
|
||||
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
if ((from_bitField0_ & 0x00000001) == 0x00000001) {
|
||||
to_bitField0_ |= 0x00000001;
|
||||
}
|
||||
result.continent_ = continent_;
|
||||
if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
if ((from_bitField0_ & 0x00000002) == 0x00000002) {
|
||||
to_bitField0_ |= 0x00000002;
|
||||
}
|
||||
result.city_ = city_;
|
||||
@ -523,14 +527,16 @@ public final class LocalTimeProtocol {
|
||||
}
|
||||
|
||||
public Builder mergeFrom(org.jboss.netty.example.localtime.LocalTimeProtocol.Location other) {
|
||||
if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.Location.getDefaultInstance()) return this;
|
||||
if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.Location.getDefaultInstance()) {
|
||||
return this;
|
||||
}
|
||||
if (other.hasContinent()) {
|
||||
setContinent(other.getContinent());
|
||||
}
|
||||
if (other.hasCity()) {
|
||||
setCity(other.getCity());
|
||||
}
|
||||
this.mergeUnknownFields(other.getUnknownFields());
|
||||
mergeUnknownFields(other.getUnknownFields());
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -552,18 +558,18 @@ public final class LocalTimeProtocol {
|
||||
throws java.io.IOException {
|
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
|
||||
com.google.protobuf.UnknownFieldSet.newBuilder(
|
||||
this.getUnknownFields());
|
||||
getUnknownFields());
|
||||
while (true) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
this.setUnknownFields(unknownFields.build());
|
||||
setUnknownFields(unknownFields.build());
|
||||
onChanged();
|
||||
return this;
|
||||
default: {
|
||||
if (!parseUnknownField(input, unknownFields,
|
||||
extensionRegistry, tag)) {
|
||||
this.setUnknownFields(unknownFields.build());
|
||||
setUnknownFields(unknownFields.build());
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
@ -594,7 +600,7 @@ public final class LocalTimeProtocol {
|
||||
// required .org.jboss.netty.example.localtime.Continent continent = 1;
|
||||
private org.jboss.netty.example.localtime.LocalTimeProtocol.Continent continent_ = org.jboss.netty.example.localtime.LocalTimeProtocol.Continent.AFRICA;
|
||||
public boolean hasContinent() {
|
||||
return ((bitField0_ & 0x00000001) == 0x00000001);
|
||||
return (bitField0_ & 0x00000001) == 0x00000001;
|
||||
}
|
||||
public org.jboss.netty.example.localtime.LocalTimeProtocol.Continent getContinent() {
|
||||
return continent_;
|
||||
@ -609,7 +615,7 @@ public final class LocalTimeProtocol {
|
||||
return this;
|
||||
}
|
||||
public Builder clearContinent() {
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
bitField0_ = bitField0_ & ~0x00000001;
|
||||
continent_ = org.jboss.netty.example.localtime.LocalTimeProtocol.Continent.AFRICA;
|
||||
onChanged();
|
||||
return this;
|
||||
@ -618,7 +624,7 @@ public final class LocalTimeProtocol {
|
||||
// required string city = 2;
|
||||
private java.lang.Object city_ = "";
|
||||
public boolean hasCity() {
|
||||
return ((bitField0_ & 0x00000002) == 0x00000002);
|
||||
return (bitField0_ & 0x00000002) == 0x00000002;
|
||||
}
|
||||
public String getCity() {
|
||||
java.lang.Object ref = city_;
|
||||
@ -640,7 +646,7 @@ public final class LocalTimeProtocol {
|
||||
return this;
|
||||
}
|
||||
public Builder clearCity() {
|
||||
bitField0_ = (bitField0_ & ~0x00000002);
|
||||
bitField0_ = bitField0_ & ~0x00000002;
|
||||
city_ = getDefaultInstance().getCity();
|
||||
onChanged();
|
||||
return this;
|
||||
@ -730,7 +736,9 @@ public final class LocalTimeProtocol {
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized != -1) return isInitialized == 1;
|
||||
if (isInitialized != -1) {
|
||||
return isInitialized == 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < getLocationCount(); i++) {
|
||||
if (!getLocation(i).isInitialized()) {
|
||||
@ -754,7 +762,9 @@ public final class LocalTimeProtocol {
|
||||
private int memoizedSerializedSize = -1;
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSerializedSize;
|
||||
if (size != -1) return size;
|
||||
if (size != -1) {
|
||||
return size;
|
||||
}
|
||||
|
||||
size = 0;
|
||||
for (int i = 0; i < location_.size(); i++) {
|
||||
@ -888,7 +898,7 @@ public final class LocalTimeProtocol {
|
||||
super.clear();
|
||||
if (locationBuilder_ == null) {
|
||||
location_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
bitField0_ = bitField0_ & ~0x00000001;
|
||||
} else {
|
||||
locationBuilder_.clear();
|
||||
}
|
||||
@ -930,9 +940,9 @@ public final class LocalTimeProtocol {
|
||||
org.jboss.netty.example.localtime.LocalTimeProtocol.Locations result = new org.jboss.netty.example.localtime.LocalTimeProtocol.Locations(this);
|
||||
int from_bitField0_ = bitField0_;
|
||||
if (locationBuilder_ == null) {
|
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
if ((bitField0_ & 0x00000001) == 0x00000001) {
|
||||
location_ = java.util.Collections.unmodifiableList(location_);
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
bitField0_ = bitField0_ & ~0x00000001;
|
||||
}
|
||||
result.location_ = location_;
|
||||
} else {
|
||||
@ -952,12 +962,14 @@ public final class LocalTimeProtocol {
|
||||
}
|
||||
|
||||
public Builder mergeFrom(org.jboss.netty.example.localtime.LocalTimeProtocol.Locations other) {
|
||||
if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.Locations.getDefaultInstance()) return this;
|
||||
if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.Locations.getDefaultInstance()) {
|
||||
return this;
|
||||
}
|
||||
if (locationBuilder_ == null) {
|
||||
if (!other.location_.isEmpty()) {
|
||||
if (location_.isEmpty()) {
|
||||
location_ = other.location_;
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
bitField0_ = bitField0_ & ~0x00000001;
|
||||
} else {
|
||||
ensureLocationIsMutable();
|
||||
location_.addAll(other.location_);
|
||||
@ -970,7 +982,7 @@ public final class LocalTimeProtocol {
|
||||
locationBuilder_.dispose();
|
||||
locationBuilder_ = null;
|
||||
location_ = other.location_;
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
bitField0_ = bitField0_ & ~0x00000001;
|
||||
locationBuilder_ =
|
||||
com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
|
||||
getLocationFieldBuilder() : null;
|
||||
@ -979,7 +991,7 @@ public final class LocalTimeProtocol {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mergeUnknownFields(other.getUnknownFields());
|
||||
mergeUnknownFields(other.getUnknownFields());
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -999,18 +1011,18 @@ public final class LocalTimeProtocol {
|
||||
throws java.io.IOException {
|
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
|
||||
com.google.protobuf.UnknownFieldSet.newBuilder(
|
||||
this.getUnknownFields());
|
||||
getUnknownFields());
|
||||
while (true) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
this.setUnknownFields(unknownFields.build());
|
||||
setUnknownFields(unknownFields.build());
|
||||
onChanged();
|
||||
return this;
|
||||
default: {
|
||||
if (!parseUnknownField(input, unknownFields,
|
||||
extensionRegistry, tag)) {
|
||||
this.setUnknownFields(unknownFields.build());
|
||||
setUnknownFields(unknownFields.build());
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
@ -1150,7 +1162,7 @@ public final class LocalTimeProtocol {
|
||||
public Builder clearLocation() {
|
||||
if (locationBuilder_ == null) {
|
||||
location_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
bitField0_ = bitField0_ & ~0x00000001;
|
||||
onChanged();
|
||||
} else {
|
||||
locationBuilder_.clear();
|
||||
@ -1206,7 +1218,7 @@ public final class LocalTimeProtocol {
|
||||
locationBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
|
||||
org.jboss.netty.example.localtime.LocalTimeProtocol.Location, org.jboss.netty.example.localtime.LocalTimeProtocol.Location.Builder, org.jboss.netty.example.localtime.LocalTimeProtocol.LocationOrBuilder>(
|
||||
location_,
|
||||
((bitField0_ & 0x00000001) == 0x00000001),
|
||||
(bitField0_ & 0x00000001) == 0x00000001,
|
||||
getParentForChildren(),
|
||||
isClean());
|
||||
location_ = null;
|
||||
@ -1289,7 +1301,7 @@ public final class LocalTimeProtocol {
|
||||
public static final int YEAR_FIELD_NUMBER = 1;
|
||||
private int year_;
|
||||
public boolean hasYear() {
|
||||
return ((bitField0_ & 0x00000001) == 0x00000001);
|
||||
return (bitField0_ & 0x00000001) == 0x00000001;
|
||||
}
|
||||
public int getYear() {
|
||||
return year_;
|
||||
@ -1299,7 +1311,7 @@ public final class LocalTimeProtocol {
|
||||
public static final int MONTH_FIELD_NUMBER = 2;
|
||||
private int month_;
|
||||
public boolean hasMonth() {
|
||||
return ((bitField0_ & 0x00000002) == 0x00000002);
|
||||
return (bitField0_ & 0x00000002) == 0x00000002;
|
||||
}
|
||||
public int getMonth() {
|
||||
return month_;
|
||||
@ -1309,7 +1321,7 @@ public final class LocalTimeProtocol {
|
||||
public static final int DAYOFMONTH_FIELD_NUMBER = 4;
|
||||
private int dayOfMonth_;
|
||||
public boolean hasDayOfMonth() {
|
||||
return ((bitField0_ & 0x00000004) == 0x00000004);
|
||||
return (bitField0_ & 0x00000004) == 0x00000004;
|
||||
}
|
||||
public int getDayOfMonth() {
|
||||
return dayOfMonth_;
|
||||
@ -1319,7 +1331,7 @@ public final class LocalTimeProtocol {
|
||||
public static final int DAYOFWEEK_FIELD_NUMBER = 5;
|
||||
private org.jboss.netty.example.localtime.LocalTimeProtocol.DayOfWeek dayOfWeek_;
|
||||
public boolean hasDayOfWeek() {
|
||||
return ((bitField0_ & 0x00000008) == 0x00000008);
|
||||
return (bitField0_ & 0x00000008) == 0x00000008;
|
||||
}
|
||||
public org.jboss.netty.example.localtime.LocalTimeProtocol.DayOfWeek getDayOfWeek() {
|
||||
return dayOfWeek_;
|
||||
@ -1329,7 +1341,7 @@ public final class LocalTimeProtocol {
|
||||
public static final int HOUR_FIELD_NUMBER = 6;
|
||||
private int hour_;
|
||||
public boolean hasHour() {
|
||||
return ((bitField0_ & 0x00000010) == 0x00000010);
|
||||
return (bitField0_ & 0x00000010) == 0x00000010;
|
||||
}
|
||||
public int getHour() {
|
||||
return hour_;
|
||||
@ -1339,7 +1351,7 @@ public final class LocalTimeProtocol {
|
||||
public static final int MINUTE_FIELD_NUMBER = 7;
|
||||
private int minute_;
|
||||
public boolean hasMinute() {
|
||||
return ((bitField0_ & 0x00000020) == 0x00000020);
|
||||
return (bitField0_ & 0x00000020) == 0x00000020;
|
||||
}
|
||||
public int getMinute() {
|
||||
return minute_;
|
||||
@ -1349,7 +1361,7 @@ public final class LocalTimeProtocol {
|
||||
public static final int SECOND_FIELD_NUMBER = 8;
|
||||
private int second_;
|
||||
public boolean hasSecond() {
|
||||
return ((bitField0_ & 0x00000040) == 0x00000040);
|
||||
return (bitField0_ & 0x00000040) == 0x00000040;
|
||||
}
|
||||
public int getSecond() {
|
||||
return second_;
|
||||
@ -1367,7 +1379,9 @@ public final class LocalTimeProtocol {
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized != -1) return isInitialized == 1;
|
||||
if (isInitialized != -1) {
|
||||
return isInitialized == 1;
|
||||
}
|
||||
|
||||
if (!hasYear()) {
|
||||
memoizedIsInitialized = 0;
|
||||
@ -1404,25 +1418,25 @@ public final class LocalTimeProtocol {
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
getSerializedSize();
|
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
if ((bitField0_ & 0x00000001) == 0x00000001) {
|
||||
output.writeUInt32(1, year_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
if ((bitField0_ & 0x00000002) == 0x00000002) {
|
||||
output.writeUInt32(2, month_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000004) == 0x00000004)) {
|
||||
if ((bitField0_ & 0x00000004) == 0x00000004) {
|
||||
output.writeUInt32(4, dayOfMonth_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000008) == 0x00000008)) {
|
||||
if ((bitField0_ & 0x00000008) == 0x00000008) {
|
||||
output.writeEnum(5, dayOfWeek_.getNumber());
|
||||
}
|
||||
if (((bitField0_ & 0x00000010) == 0x00000010)) {
|
||||
if ((bitField0_ & 0x00000010) == 0x00000010) {
|
||||
output.writeUInt32(6, hour_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000020) == 0x00000020)) {
|
||||
if ((bitField0_ & 0x00000020) == 0x00000020) {
|
||||
output.writeUInt32(7, minute_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000040) == 0x00000040)) {
|
||||
if ((bitField0_ & 0x00000040) == 0x00000040) {
|
||||
output.writeUInt32(8, second_);
|
||||
}
|
||||
getUnknownFields().writeTo(output);
|
||||
@ -1431,34 +1445,36 @@ public final class LocalTimeProtocol {
|
||||
private int memoizedSerializedSize = -1;
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSerializedSize;
|
||||
if (size != -1) return size;
|
||||
if (size != -1) {
|
||||
return size;
|
||||
}
|
||||
|
||||
size = 0;
|
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
if ((bitField0_ & 0x00000001) == 0x00000001) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeUInt32Size(1, year_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
if ((bitField0_ & 0x00000002) == 0x00000002) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeUInt32Size(2, month_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000004) == 0x00000004)) {
|
||||
if ((bitField0_ & 0x00000004) == 0x00000004) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeUInt32Size(4, dayOfMonth_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000008) == 0x00000008)) {
|
||||
if ((bitField0_ & 0x00000008) == 0x00000008) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeEnumSize(5, dayOfWeek_.getNumber());
|
||||
}
|
||||
if (((bitField0_ & 0x00000010) == 0x00000010)) {
|
||||
if ((bitField0_ & 0x00000010) == 0x00000010) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeUInt32Size(6, hour_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000020) == 0x00000020)) {
|
||||
if ((bitField0_ & 0x00000020) == 0x00000020) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeUInt32Size(7, minute_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000040) == 0x00000040)) {
|
||||
if ((bitField0_ & 0x00000040) == 0x00000040) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeUInt32Size(8, second_);
|
||||
}
|
||||
@ -1587,19 +1603,19 @@ public final class LocalTimeProtocol {
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
year_ = 0;
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
bitField0_ = bitField0_ & ~0x00000001;
|
||||
month_ = 0;
|
||||
bitField0_ = (bitField0_ & ~0x00000002);
|
||||
bitField0_ = bitField0_ & ~0x00000002;
|
||||
dayOfMonth_ = 0;
|
||||
bitField0_ = (bitField0_ & ~0x00000004);
|
||||
bitField0_ = bitField0_ & ~0x00000004;
|
||||
dayOfWeek_ = org.jboss.netty.example.localtime.LocalTimeProtocol.DayOfWeek.SUNDAY;
|
||||
bitField0_ = (bitField0_ & ~0x00000008);
|
||||
bitField0_ = bitField0_ & ~0x00000008;
|
||||
hour_ = 0;
|
||||
bitField0_ = (bitField0_ & ~0x00000010);
|
||||
bitField0_ = bitField0_ & ~0x00000010;
|
||||
minute_ = 0;
|
||||
bitField0_ = (bitField0_ & ~0x00000020);
|
||||
bitField0_ = bitField0_ & ~0x00000020;
|
||||
second_ = 0;
|
||||
bitField0_ = (bitField0_ & ~0x00000040);
|
||||
bitField0_ = bitField0_ & ~0x00000040;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -1638,31 +1654,31 @@ public final class LocalTimeProtocol {
|
||||
org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime result = new org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime(this);
|
||||
int from_bitField0_ = bitField0_;
|
||||
int to_bitField0_ = 0;
|
||||
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
if ((from_bitField0_ & 0x00000001) == 0x00000001) {
|
||||
to_bitField0_ |= 0x00000001;
|
||||
}
|
||||
result.year_ = year_;
|
||||
if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
|
||||
if ((from_bitField0_ & 0x00000002) == 0x00000002) {
|
||||
to_bitField0_ |= 0x00000002;
|
||||
}
|
||||
result.month_ = month_;
|
||||
if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
|
||||
if ((from_bitField0_ & 0x00000004) == 0x00000004) {
|
||||
to_bitField0_ |= 0x00000004;
|
||||
}
|
||||
result.dayOfMonth_ = dayOfMonth_;
|
||||
if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
|
||||
if ((from_bitField0_ & 0x00000008) == 0x00000008) {
|
||||
to_bitField0_ |= 0x00000008;
|
||||
}
|
||||
result.dayOfWeek_ = dayOfWeek_;
|
||||
if (((from_bitField0_ & 0x00000010) == 0x00000010)) {
|
||||
if ((from_bitField0_ & 0x00000010) == 0x00000010) {
|
||||
to_bitField0_ |= 0x00000010;
|
||||
}
|
||||
result.hour_ = hour_;
|
||||
if (((from_bitField0_ & 0x00000020) == 0x00000020)) {
|
||||
if ((from_bitField0_ & 0x00000020) == 0x00000020) {
|
||||
to_bitField0_ |= 0x00000020;
|
||||
}
|
||||
result.minute_ = minute_;
|
||||
if (((from_bitField0_ & 0x00000040) == 0x00000040)) {
|
||||
if ((from_bitField0_ & 0x00000040) == 0x00000040) {
|
||||
to_bitField0_ |= 0x00000040;
|
||||
}
|
||||
result.second_ = second_;
|
||||
@ -1681,7 +1697,9 @@ public final class LocalTimeProtocol {
|
||||
}
|
||||
|
||||
public Builder mergeFrom(org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime other) {
|
||||
if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime.getDefaultInstance()) return this;
|
||||
if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime.getDefaultInstance()) {
|
||||
return this;
|
||||
}
|
||||
if (other.hasYear()) {
|
||||
setYear(other.getYear());
|
||||
}
|
||||
@ -1703,7 +1721,7 @@ public final class LocalTimeProtocol {
|
||||
if (other.hasSecond()) {
|
||||
setSecond(other.getSecond());
|
||||
}
|
||||
this.mergeUnknownFields(other.getUnknownFields());
|
||||
mergeUnknownFields(other.getUnknownFields());
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -1745,18 +1763,18 @@ public final class LocalTimeProtocol {
|
||||
throws java.io.IOException {
|
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
|
||||
com.google.protobuf.UnknownFieldSet.newBuilder(
|
||||
this.getUnknownFields());
|
||||
getUnknownFields());
|
||||
while (true) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
this.setUnknownFields(unknownFields.build());
|
||||
setUnknownFields(unknownFields.build());
|
||||
onChanged();
|
||||
return this;
|
||||
default: {
|
||||
if (!parseUnknownField(input, unknownFields,
|
||||
extensionRegistry, tag)) {
|
||||
this.setUnknownFields(unknownFields.build());
|
||||
setUnknownFields(unknownFields.build());
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
@ -1812,7 +1830,7 @@ public final class LocalTimeProtocol {
|
||||
// required uint32 year = 1;
|
||||
private int year_ ;
|
||||
public boolean hasYear() {
|
||||
return ((bitField0_ & 0x00000001) == 0x00000001);
|
||||
return (bitField0_ & 0x00000001) == 0x00000001;
|
||||
}
|
||||
public int getYear() {
|
||||
return year_;
|
||||
@ -1824,7 +1842,7 @@ public final class LocalTimeProtocol {
|
||||
return this;
|
||||
}
|
||||
public Builder clearYear() {
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
bitField0_ = bitField0_ & ~0x00000001;
|
||||
year_ = 0;
|
||||
onChanged();
|
||||
return this;
|
||||
@ -1833,7 +1851,7 @@ public final class LocalTimeProtocol {
|
||||
// required uint32 month = 2;
|
||||
private int month_ ;
|
||||
public boolean hasMonth() {
|
||||
return ((bitField0_ & 0x00000002) == 0x00000002);
|
||||
return (bitField0_ & 0x00000002) == 0x00000002;
|
||||
}
|
||||
public int getMonth() {
|
||||
return month_;
|
||||
@ -1845,7 +1863,7 @@ public final class LocalTimeProtocol {
|
||||
return this;
|
||||
}
|
||||
public Builder clearMonth() {
|
||||
bitField0_ = (bitField0_ & ~0x00000002);
|
||||
bitField0_ = bitField0_ & ~0x00000002;
|
||||
month_ = 0;
|
||||
onChanged();
|
||||
return this;
|
||||
@ -1854,7 +1872,7 @@ public final class LocalTimeProtocol {
|
||||
// required uint32 dayOfMonth = 4;
|
||||
private int dayOfMonth_ ;
|
||||
public boolean hasDayOfMonth() {
|
||||
return ((bitField0_ & 0x00000004) == 0x00000004);
|
||||
return (bitField0_ & 0x00000004) == 0x00000004;
|
||||
}
|
||||
public int getDayOfMonth() {
|
||||
return dayOfMonth_;
|
||||
@ -1866,7 +1884,7 @@ public final class LocalTimeProtocol {
|
||||
return this;
|
||||
}
|
||||
public Builder clearDayOfMonth() {
|
||||
bitField0_ = (bitField0_ & ~0x00000004);
|
||||
bitField0_ = bitField0_ & ~0x00000004;
|
||||
dayOfMonth_ = 0;
|
||||
onChanged();
|
||||
return this;
|
||||
@ -1875,7 +1893,7 @@ public final class LocalTimeProtocol {
|
||||
// required .org.jboss.netty.example.localtime.DayOfWeek dayOfWeek = 5;
|
||||
private org.jboss.netty.example.localtime.LocalTimeProtocol.DayOfWeek dayOfWeek_ = org.jboss.netty.example.localtime.LocalTimeProtocol.DayOfWeek.SUNDAY;
|
||||
public boolean hasDayOfWeek() {
|
||||
return ((bitField0_ & 0x00000008) == 0x00000008);
|
||||
return (bitField0_ & 0x00000008) == 0x00000008;
|
||||
}
|
||||
public org.jboss.netty.example.localtime.LocalTimeProtocol.DayOfWeek getDayOfWeek() {
|
||||
return dayOfWeek_;
|
||||
@ -1890,7 +1908,7 @@ public final class LocalTimeProtocol {
|
||||
return this;
|
||||
}
|
||||
public Builder clearDayOfWeek() {
|
||||
bitField0_ = (bitField0_ & ~0x00000008);
|
||||
bitField0_ = bitField0_ & ~0x00000008;
|
||||
dayOfWeek_ = org.jboss.netty.example.localtime.LocalTimeProtocol.DayOfWeek.SUNDAY;
|
||||
onChanged();
|
||||
return this;
|
||||
@ -1899,7 +1917,7 @@ public final class LocalTimeProtocol {
|
||||
// required uint32 hour = 6;
|
||||
private int hour_ ;
|
||||
public boolean hasHour() {
|
||||
return ((bitField0_ & 0x00000010) == 0x00000010);
|
||||
return (bitField0_ & 0x00000010) == 0x00000010;
|
||||
}
|
||||
public int getHour() {
|
||||
return hour_;
|
||||
@ -1911,7 +1929,7 @@ public final class LocalTimeProtocol {
|
||||
return this;
|
||||
}
|
||||
public Builder clearHour() {
|
||||
bitField0_ = (bitField0_ & ~0x00000010);
|
||||
bitField0_ = bitField0_ & ~0x00000010;
|
||||
hour_ = 0;
|
||||
onChanged();
|
||||
return this;
|
||||
@ -1920,7 +1938,7 @@ public final class LocalTimeProtocol {
|
||||
// required uint32 minute = 7;
|
||||
private int minute_ ;
|
||||
public boolean hasMinute() {
|
||||
return ((bitField0_ & 0x00000020) == 0x00000020);
|
||||
return (bitField0_ & 0x00000020) == 0x00000020;
|
||||
}
|
||||
public int getMinute() {
|
||||
return minute_;
|
||||
@ -1932,7 +1950,7 @@ public final class LocalTimeProtocol {
|
||||
return this;
|
||||
}
|
||||
public Builder clearMinute() {
|
||||
bitField0_ = (bitField0_ & ~0x00000020);
|
||||
bitField0_ = bitField0_ & ~0x00000020;
|
||||
minute_ = 0;
|
||||
onChanged();
|
||||
return this;
|
||||
@ -1941,7 +1959,7 @@ public final class LocalTimeProtocol {
|
||||
// required uint32 second = 8;
|
||||
private int second_ ;
|
||||
public boolean hasSecond() {
|
||||
return ((bitField0_ & 0x00000040) == 0x00000040);
|
||||
return (bitField0_ & 0x00000040) == 0x00000040;
|
||||
}
|
||||
public int getSecond() {
|
||||
return second_;
|
||||
@ -1953,7 +1971,7 @@ public final class LocalTimeProtocol {
|
||||
return this;
|
||||
}
|
||||
public Builder clearSecond() {
|
||||
bitField0_ = (bitField0_ & ~0x00000040);
|
||||
bitField0_ = bitField0_ & ~0x00000040;
|
||||
second_ = 0;
|
||||
onChanged();
|
||||
return this;
|
||||
@ -2038,7 +2056,9 @@ public final class LocalTimeProtocol {
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized != -1) return isInitialized == 1;
|
||||
if (isInitialized != -1) {
|
||||
return isInitialized == 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < getLocalTimeCount(); i++) {
|
||||
if (!getLocalTime(i).isInitialized()) {
|
||||
@ -2062,7 +2082,9 @@ public final class LocalTimeProtocol {
|
||||
private int memoizedSerializedSize = -1;
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSerializedSize;
|
||||
if (size != -1) return size;
|
||||
if (size != -1) {
|
||||
return size;
|
||||
}
|
||||
|
||||
size = 0;
|
||||
for (int i = 0; i < localTime_.size(); i++) {
|
||||
@ -2196,7 +2218,7 @@ public final class LocalTimeProtocol {
|
||||
super.clear();
|
||||
if (localTimeBuilder_ == null) {
|
||||
localTime_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
bitField0_ = bitField0_ & ~0x00000001;
|
||||
} else {
|
||||
localTimeBuilder_.clear();
|
||||
}
|
||||
@ -2238,9 +2260,9 @@ public final class LocalTimeProtocol {
|
||||
org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes result = new org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes(this);
|
||||
int from_bitField0_ = bitField0_;
|
||||
if (localTimeBuilder_ == null) {
|
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) {
|
||||
if ((bitField0_ & 0x00000001) == 0x00000001) {
|
||||
localTime_ = java.util.Collections.unmodifiableList(localTime_);
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
bitField0_ = bitField0_ & ~0x00000001;
|
||||
}
|
||||
result.localTime_ = localTime_;
|
||||
} else {
|
||||
@ -2260,12 +2282,14 @@ public final class LocalTimeProtocol {
|
||||
}
|
||||
|
||||
public Builder mergeFrom(org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes other) {
|
||||
if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes.getDefaultInstance()) return this;
|
||||
if (other == org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimes.getDefaultInstance()) {
|
||||
return this;
|
||||
}
|
||||
if (localTimeBuilder_ == null) {
|
||||
if (!other.localTime_.isEmpty()) {
|
||||
if (localTime_.isEmpty()) {
|
||||
localTime_ = other.localTime_;
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
bitField0_ = bitField0_ & ~0x00000001;
|
||||
} else {
|
||||
ensureLocalTimeIsMutable();
|
||||
localTime_.addAll(other.localTime_);
|
||||
@ -2278,7 +2302,7 @@ public final class LocalTimeProtocol {
|
||||
localTimeBuilder_.dispose();
|
||||
localTimeBuilder_ = null;
|
||||
localTime_ = other.localTime_;
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
bitField0_ = bitField0_ & ~0x00000001;
|
||||
localTimeBuilder_ =
|
||||
com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
|
||||
getLocalTimeFieldBuilder() : null;
|
||||
@ -2287,7 +2311,7 @@ public final class LocalTimeProtocol {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mergeUnknownFields(other.getUnknownFields());
|
||||
mergeUnknownFields(other.getUnknownFields());
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -2307,18 +2331,18 @@ public final class LocalTimeProtocol {
|
||||
throws java.io.IOException {
|
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
|
||||
com.google.protobuf.UnknownFieldSet.newBuilder(
|
||||
this.getUnknownFields());
|
||||
getUnknownFields());
|
||||
while (true) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
this.setUnknownFields(unknownFields.build());
|
||||
setUnknownFields(unknownFields.build());
|
||||
onChanged();
|
||||
return this;
|
||||
default: {
|
||||
if (!parseUnknownField(input, unknownFields,
|
||||
extensionRegistry, tag)) {
|
||||
this.setUnknownFields(unknownFields.build());
|
||||
setUnknownFields(unknownFields.build());
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
@ -2458,7 +2482,7 @@ public final class LocalTimeProtocol {
|
||||
public Builder clearLocalTime() {
|
||||
if (localTimeBuilder_ == null) {
|
||||
localTime_ = java.util.Collections.emptyList();
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
bitField0_ = bitField0_ & ~0x00000001;
|
||||
onChanged();
|
||||
} else {
|
||||
localTimeBuilder_.clear();
|
||||
@ -2514,7 +2538,7 @@ public final class LocalTimeProtocol {
|
||||
localTimeBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
|
||||
org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime, org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTime.Builder, org.jboss.netty.example.localtime.LocalTimeProtocol.LocalTimeOrBuilder>(
|
||||
localTime_,
|
||||
((bitField0_ & 0x00000001) == 0x00000001),
|
||||
(bitField0_ & 0x00000001) == 0x00000001,
|
||||
getParentForChildren(),
|
||||
isClean());
|
||||
localTime_ = null;
|
||||
|
@ -16,7 +16,6 @@
|
||||
package org.jboss.netty.example.qotm;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
@ -44,9 +43,7 @@ public class QuoteOfTheMomentServer {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
DatagramChannelFactory f =
|
||||
new NioDatagramChannelFactory(Executors.newCachedThreadPool());
|
||||
|
||||
DatagramChannelFactory f = new NioDatagramChannelFactory();
|
||||
ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
|
||||
|
||||
// Configure the pipeline factory.
|
||||
|
@ -18,9 +18,9 @@ package org.jboss.netty.handler.codec.base64;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
|
||||
import org.jboss.netty.handler.codec.frame.Delimiters;
|
||||
import org.jboss.netty.handler.codec.frame.FrameDecoder;
|
||||
|
@ -17,9 +17,9 @@ package org.jboss.netty.handler.codec.base64;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
|
||||
import org.jboss.netty.handler.codec.frame.Delimiters;
|
||||
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
|
||||
|
@ -31,6 +31,7 @@ import org.jboss.netty.channel.ExceptionEvent;
|
||||
import org.jboss.netty.channel.LifeCycleAwareChannelHandler;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
||||
import org.jboss.netty.handler.codec.replay.ReplayingDecoder;
|
||||
|
||||
/**
|
||||
* Decodes the received {@link ChannelBuffer}s into a meaningful frame object.
|
||||
@ -452,7 +453,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
|
||||
* Use it only when you must use it at your own risk.
|
||||
*/
|
||||
protected ChannelBuffer internalBuffer() {
|
||||
ChannelBuffer buf = this.cumulation;
|
||||
ChannelBuffer buf = cumulation;
|
||||
if (buf == null) {
|
||||
return ChannelBuffers.EMPTY_BUFFER;
|
||||
}
|
||||
@ -465,17 +466,14 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
|
||||
|
||||
public void afterAdd(ChannelHandlerContext ctx) throws Exception {
|
||||
// Nothing to do..
|
||||
|
||||
}
|
||||
|
||||
public void beforeRemove(ChannelHandlerContext ctx) throws Exception {
|
||||
// Nothing to do..
|
||||
|
||||
}
|
||||
|
||||
public void afterRemove(ChannelHandlerContext ctx) throws Exception {
|
||||
// Nothing to do..
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -402,14 +402,14 @@ public class LengthFieldBasedFrameDecoder extends FrameDecoder {
|
||||
long tooLongFrameLength = this.tooLongFrameLength;
|
||||
this.tooLongFrameLength = 0;
|
||||
discardingTooLongFrame = false;
|
||||
if ((!failFast) ||
|
||||
(failFast && firstDetectionOfTooLongFrame)) {
|
||||
if (!failFast ||
|
||||
failFast && firstDetectionOfTooLongFrame) {
|
||||
fail(ctx, tooLongFrameLength);
|
||||
}
|
||||
} else {
|
||||
// Keep discarding and notify handlers if necessary.
|
||||
if (failFast && firstDetectionOfTooLongFrame) {
|
||||
fail(ctx, this.tooLongFrameLength);
|
||||
fail(ctx, tooLongFrameLength);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,8 @@ import java.nio.ByteOrder;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
|
||||
|
||||
/**
|
||||
|
@ -130,11 +130,11 @@ public class CookieEncoder {
|
||||
}
|
||||
if (cookie.isSecure()) {
|
||||
sb.append(CookieHeaderNames.SECURE);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
if (cookie.isHttpOnly()) {
|
||||
sb.append(CookieHeaderNames.HTTPONLY);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
if (cookie.getVersion() >= 1) {
|
||||
if (cookie.getComment() != null) {
|
||||
@ -149,18 +149,18 @@ public class CookieEncoder {
|
||||
|
||||
if (!cookie.getPorts().isEmpty()) {
|
||||
sb.append(CookieHeaderNames.PORT);
|
||||
sb.append((char) HttpCodecUtil.EQUALS);
|
||||
sb.append((char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpConstants.EQUALS);
|
||||
sb.append((char) HttpConstants.DOUBLE_QUOTE);
|
||||
for (int port: cookie.getPorts()) {
|
||||
sb.append(port);
|
||||
sb.append((char) HttpCodecUtil.COMMA);
|
||||
sb.append((char) HttpConstants.COMMA);
|
||||
}
|
||||
sb.setCharAt(sb.length() - 1, (char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.setCharAt(sb.length() - 1, (char) HttpConstants.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
if (cookie.isDiscard()) {
|
||||
sb.append(CookieHeaderNames.DISCARD);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,14 +194,14 @@ public class CookieEncoder {
|
||||
if (!cookie.getPorts().isEmpty()) {
|
||||
sb.append('$');
|
||||
sb.append(CookieHeaderNames.PORT);
|
||||
sb.append((char) HttpCodecUtil.EQUALS);
|
||||
sb.append((char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpConstants.EQUALS);
|
||||
sb.append((char) HttpConstants.DOUBLE_QUOTE);
|
||||
for (int port: cookie.getPorts()) {
|
||||
sb.append(port);
|
||||
sb.append((char) HttpCodecUtil.COMMA);
|
||||
sb.append((char) HttpConstants.COMMA);
|
||||
}
|
||||
sb.setCharAt(sb.length() - 1, (char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.setCharAt(sb.length() - 1, (char) HttpConstants.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -235,9 +235,9 @@ public class CookieEncoder {
|
||||
|
||||
private static void addUnquoted(StringBuilder sb, String name, String val) {
|
||||
sb.append(name);
|
||||
sb.append((char) HttpCodecUtil.EQUALS);
|
||||
sb.append((char) HttpConstants.EQUALS);
|
||||
sb.append(val);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
|
||||
private static void addQuoted(StringBuilder sb, String name, String val) {
|
||||
@ -246,17 +246,17 @@ public class CookieEncoder {
|
||||
}
|
||||
|
||||
sb.append(name);
|
||||
sb.append((char) HttpCodecUtil.EQUALS);
|
||||
sb.append((char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpConstants.EQUALS);
|
||||
sb.append((char) HttpConstants.DOUBLE_QUOTE);
|
||||
sb.append(val.replace("\\", "\\\\").replace("\"", "\\\""));
|
||||
sb.append((char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.append((char) HttpConstants.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
|
||||
private static void add(StringBuilder sb, String name, int val) {
|
||||
sb.append(name);
|
||||
sb.append((char) HttpCodecUtil.EQUALS);
|
||||
sb.append((char) HttpConstants.EQUALS);
|
||||
sb.append(val);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.jboss.netty.util.internal.CaseIgnoringComparator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -15,60 +15,9 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
import org.jboss.netty.util.CharsetUtil;
|
||||
|
||||
final class HttpCodecUtil {
|
||||
//space ' '
|
||||
static final byte SP = 32;
|
||||
|
||||
//tab ' '
|
||||
static final byte HT = 9;
|
||||
|
||||
/**
|
||||
* Carriage return
|
||||
*/
|
||||
static final byte CR = 13;
|
||||
|
||||
/**
|
||||
* Equals '='
|
||||
*/
|
||||
static final byte EQUALS = 61;
|
||||
|
||||
/**
|
||||
* Line feed character
|
||||
*/
|
||||
static final byte LF = 10;
|
||||
|
||||
/**
|
||||
* carriage return line feed
|
||||
*/
|
||||
static final byte[] CRLF = new byte[] { CR, LF };
|
||||
|
||||
/**
|
||||
* Colon ':'
|
||||
*/
|
||||
static final byte COLON = 58;
|
||||
|
||||
/**
|
||||
* Semicolon ';'
|
||||
*/
|
||||
static final byte SEMICOLON = 59;
|
||||
|
||||
/**
|
||||
* comma ','
|
||||
*/
|
||||
static final byte COMMA = 44;
|
||||
|
||||
static final byte DOUBLE_QUOTE = '"';
|
||||
|
||||
static final Charset DEFAULT_CHARSET = CharsetUtil.UTF_8;
|
||||
|
||||
private HttpCodecUtil() {
|
||||
super();
|
||||
}
|
||||
|
||||
static void validateHeaderName(String name) {
|
||||
if (name == null) {
|
||||
@ -168,4 +117,8 @@ final class HttpCodecUtil {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private HttpCodecUtil() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright 2012 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.jboss.netty.util.CharsetUtil;
|
||||
|
||||
public final class HttpConstants {
|
||||
|
||||
/**
|
||||
* Horizontal space
|
||||
*/
|
||||
public static final byte SP = 32;
|
||||
|
||||
/**
|
||||
* Horizontal tab
|
||||
*/
|
||||
public static final byte HT = 9;
|
||||
|
||||
/**
|
||||
* Carriage return
|
||||
*/
|
||||
public static final byte CR = 13;
|
||||
|
||||
/**
|
||||
* Equals '='
|
||||
*/
|
||||
public static final byte EQUALS = 61;
|
||||
|
||||
/**
|
||||
* Line feed character
|
||||
*/
|
||||
public static final byte LF = 10;
|
||||
|
||||
/**
|
||||
* Colon ':'
|
||||
*/
|
||||
public static final byte COLON = 58;
|
||||
|
||||
/**
|
||||
* Semicolon ';'
|
||||
*/
|
||||
public static final byte SEMICOLON = 59;
|
||||
|
||||
/**
|
||||
* Comma ','
|
||||
*/
|
||||
public static final byte COMMA = 44;
|
||||
|
||||
/**
|
||||
* Double quote '"'
|
||||
*/
|
||||
public static final byte DOUBLE_QUOTE = '"';
|
||||
|
||||
/**
|
||||
* Default character set (UTF-8)
|
||||
*/
|
||||
public static final Charset DEFAULT_CHARSET = CharsetUtil.UTF_8;
|
||||
|
||||
private HttpConstants() {
|
||||
// Unused
|
||||
}
|
||||
}
|
@ -21,6 +21,8 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.jboss.netty.util.internal.CaseIgnoringComparator;
|
||||
|
||||
|
||||
/**
|
||||
* Provides the constants for the standard HTTP header names and values and
|
||||
@ -321,7 +323,7 @@ public class HttpHeaders {
|
||||
/**
|
||||
* {@code "boundary"}
|
||||
*/
|
||||
static final String BOUNDARY = "boundary";
|
||||
public static final String BOUNDARY = "boundary";
|
||||
/**
|
||||
* {@code "bytes"}
|
||||
*/
|
||||
@ -377,7 +379,7 @@ public class HttpHeaders {
|
||||
/**
|
||||
* {@code "multipart/form-data"}
|
||||
*/
|
||||
static final String MULTIPART_FORM_DATA = "multipart/form-data";
|
||||
public static final String MULTIPART_FORM_DATA = "multipart/form-data";
|
||||
/**
|
||||
* {@code "must-revalidate"}
|
||||
*/
|
||||
|
@ -335,12 +335,12 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
||||
case READ_CHUNK_DELIMITER: {
|
||||
for (;;) {
|
||||
byte next = buffer.readByte();
|
||||
if (next == HttpCodecUtil.CR) {
|
||||
if (buffer.readByte() == HttpCodecUtil.LF) {
|
||||
if (next == HttpConstants.CR) {
|
||||
if (buffer.readByte() == HttpConstants.LF) {
|
||||
checkpoint(State.READ_CHUNK_SIZE);
|
||||
return null;
|
||||
}
|
||||
} else if (next == HttpCodecUtil.LF) {
|
||||
} else if (next == HttpConstants.LF) {
|
||||
checkpoint(State.READ_CHUNK_SIZE);
|
||||
return null;
|
||||
}
|
||||
@ -524,14 +524,14 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
||||
headerSize ++;
|
||||
|
||||
switch (nextByte) {
|
||||
case HttpCodecUtil.CR:
|
||||
case HttpConstants.CR:
|
||||
nextByte = (char) buffer.readByte();
|
||||
headerSize ++;
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
break loop;
|
||||
}
|
||||
break;
|
||||
case HttpCodecUtil.LF:
|
||||
case HttpConstants.LF:
|
||||
break loop;
|
||||
}
|
||||
|
||||
@ -575,12 +575,12 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
|
||||
int lineLength = 0;
|
||||
while (true) {
|
||||
byte nextByte = buffer.readByte();
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
nextByte = buffer.readByte();
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
return sb.toString();
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
return sb.toString();
|
||||
} else {
|
||||
if (lineLength >= maxLineLength) {
|
||||
|
@ -16,7 +16,7 @@
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
|
||||
import static org.jboss.netty.buffer.ChannelBuffers.*;
|
||||
import static org.jboss.netty.handler.codec.http.HttpCodecUtil.*;
|
||||
import static org.jboss.netty.handler.codec.http.HttpConstants.*;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Map;
|
||||
@ -46,6 +46,7 @@ import org.jboss.netty.util.CharsetUtil;
|
||||
*/
|
||||
public abstract class HttpMessageEncoder extends OneToOneEncoder {
|
||||
|
||||
private static final byte[] CRLF = new byte[] { CR, LF };
|
||||
private static final ChannelBuffer LAST_CHUNK =
|
||||
copiedBuffer("0\r\n\r\n", CharsetUtil.US_ASCII);
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
|
||||
import static org.jboss.netty.handler.codec.http.HttpCodecUtil.*;
|
||||
import static org.jboss.netty.handler.codec.http.HttpConstants.*;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
|
||||
import static org.jboss.netty.handler.codec.http.HttpCodecUtil.*;
|
||||
import static org.jboss.netty.handler.codec.http.HttpConstants.*;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class QueryStringDecoder {
|
||||
* assume that the query string is encoded in UTF-8.
|
||||
*/
|
||||
public QueryStringDecoder(String uri) {
|
||||
this(uri, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
this(uri, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,7 +82,7 @@ public class QueryStringDecoder {
|
||||
* specified charset.
|
||||
*/
|
||||
public QueryStringDecoder(String uri, boolean hasPath) {
|
||||
this(uri, HttpCodecUtil.DEFAULT_CHARSET, hasPath);
|
||||
this(uri, HttpConstants.DEFAULT_CHARSET, hasPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,7 +137,7 @@ public class QueryStringDecoder {
|
||||
* assume that the query string is encoded in UTF-8.
|
||||
*/
|
||||
public QueryStringDecoder(URI uri) {
|
||||
this(uri, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
this(uri, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -305,7 +305,7 @@ public class QueryStringDecoder {
|
||||
* escape sequence.
|
||||
*/
|
||||
public static String decodeComponent(final String s) {
|
||||
return decodeComponent(s, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
return decodeComponent(s, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@ public class QueryStringEncoder {
|
||||
* path string. The encoder will encode the URI in UTF-8.
|
||||
*/
|
||||
public QueryStringEncoder(String uri) {
|
||||
this(uri, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
this(uri, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -26,6 +26,7 @@ import java.nio.charset.Charset;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.handler.codec.http.HttpConstants;
|
||||
|
||||
/**
|
||||
* Abstract Disk HttpData implementation
|
||||
@ -259,7 +260,7 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||
}
|
||||
|
||||
public String getString() throws IOException {
|
||||
return getString(HttpCodecUtil.DEFAULT_CHARSET);
|
||||
return getString(HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
public String getString(Charset encoding) throws IOException {
|
||||
@ -268,7 +269,7 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||
}
|
||||
if (encoding == null) {
|
||||
byte[] array = readFrom(file);
|
||||
return new String(array, HttpCodecUtil.DEFAULT_CHARSET.name());
|
||||
return new String(array, HttpConstants.DEFAULT_CHARSET.name());
|
||||
}
|
||||
byte[] array = readFrom(file);
|
||||
return new String(array, encoding.name());
|
@ -13,10 +13,12 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.jboss.netty.handler.codec.http.HttpConstants;
|
||||
|
||||
/**
|
||||
* Abstract HttpData implementation
|
||||
*/
|
||||
@ -25,7 +27,7 @@ public abstract class AbstractHttpData implements HttpData {
|
||||
protected final String name;
|
||||
protected long definedSize;
|
||||
protected long size;
|
||||
protected Charset charset = HttpCodecUtil.DEFAULT_CHARSET;
|
||||
protected Charset charset = HttpConstants.DEFAULT_CHARSET;
|
||||
protected boolean completed;
|
||||
|
||||
public AbstractHttpData(String name, Charset charset, long size) {
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -26,6 +26,7 @@ import java.nio.charset.Charset;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.handler.codec.http.HttpConstants;
|
||||
|
||||
/**
|
||||
* Abstract Memory HttpData implementation
|
||||
@ -138,7 +139,7 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return getString(HttpCodecUtil.DEFAULT_CHARSET);
|
||||
return getString(HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
public String getString(Charset encoding) {
|
||||
@ -146,7 +147,7 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||
return "";
|
||||
}
|
||||
if (encoding == null) {
|
||||
return getString(HttpCodecUtil.DEFAULT_CHARSET);
|
||||
return getString(HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
return channelBuffer.toString(encoding);
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
@ -21,6 +21,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.jboss.netty.handler.codec.http.HttpRequest;
|
||||
|
||||
/**
|
||||
* Default factory giving Attribute and FileUpload according to constructor
|
||||
*
|
||||
@ -35,9 +37,9 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
|
||||
*/
|
||||
public static long MINSIZE = 0x4000;
|
||||
|
||||
private boolean useDisk;
|
||||
private final boolean useDisk;
|
||||
|
||||
private boolean checkSize;
|
||||
private final boolean checkSize;
|
||||
|
||||
private long minSize;
|
||||
|
||||
@ -53,7 +55,7 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
|
||||
public DefaultHttpDataFactory() {
|
||||
useDisk = false;
|
||||
checkSize = true;
|
||||
this.minSize = MINSIZE;
|
||||
minSize = MINSIZE;
|
||||
}
|
||||
|
||||
/**
|
@ -13,12 +13,13 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.handler.codec.http.HttpConstants;
|
||||
|
||||
/**
|
||||
* Disk implementation of Attributes
|
||||
@ -37,7 +38,7 @@ public class DiskAttribute extends AbstractDiskHttpData implements Attribute {
|
||||
* @param name
|
||||
*/
|
||||
public DiskAttribute(String name) {
|
||||
super(name, HttpCodecUtil.DEFAULT_CHARSET, 0);
|
||||
super(name, HttpConstants.DEFAULT_CHARSET, 0);
|
||||
}
|
||||
/**
|
||||
*
|
||||
@ -48,7 +49,7 @@ public class DiskAttribute extends AbstractDiskHttpData implements Attribute {
|
||||
* @throws IOException
|
||||
*/
|
||||
public DiskAttribute(String name, String value) throws IOException {
|
||||
super(name, HttpCodecUtil.DEFAULT_CHARSET, 0); // Attribute have no default size
|
||||
super(name, HttpConstants.DEFAULT_CHARSET, 0); // Attribute have no default size
|
||||
setValue(value);
|
||||
}
|
||||
|
@ -13,11 +13,13 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.jboss.netty.handler.codec.http.HttpHeaders;
|
||||
|
||||
/**
|
||||
* Disk FileUpload implementation that stores file into real files
|
||||
*/
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
/**
|
||||
* FileUpload interface that could be in memory, on temporary file or any other implementations.
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
@ -13,10 +13,12 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.jboss.netty.handler.codec.http.HttpRequest;
|
||||
|
||||
/**
|
||||
* Interface to enable creation of InterfaceHttpData objects
|
||||
*/
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
@ -147,9 +147,9 @@ final class HttpPostBodyUtil {
|
||||
throw new SeekAheadNoBackArrayException();
|
||||
}
|
||||
this.buffer = buffer;
|
||||
this.bytes = buffer.array();
|
||||
this.pos = this.readerIndex = buffer.readerIndex();
|
||||
this.limit = buffer.writerIndex();
|
||||
bytes = buffer.array();
|
||||
pos = readerIndex = buffer.readerIndex();
|
||||
limit = buffer.writerIndex();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,11 +164,11 @@ final class HttpPostBodyUtil {
|
||||
}
|
||||
|
||||
void clear() {
|
||||
this.buffer = null;
|
||||
this.bytes = null;
|
||||
this.limit = 0;
|
||||
this.pos = 0;
|
||||
this.readerIndex = 0;
|
||||
buffer = null;
|
||||
bytes = null;
|
||||
limit = 0;
|
||||
pos = 0;
|
||||
readerIndex = 0;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@ -26,9 +26,15 @@ import java.util.TreeMap;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.handler.codec.http.HttpPostBodyUtil.SeekAheadNoBackArrayException;
|
||||
import org.jboss.netty.handler.codec.http.HttpPostBodyUtil.SeekAheadOptimize;
|
||||
import org.jboss.netty.handler.codec.http.HttpPostBodyUtil.TransferEncodingMechanism;
|
||||
import org.jboss.netty.handler.codec.http.HttpChunk;
|
||||
import org.jboss.netty.handler.codec.http.HttpConstants;
|
||||
import org.jboss.netty.handler.codec.http.HttpHeaders;
|
||||
import org.jboss.netty.handler.codec.http.HttpMethod;
|
||||
import org.jboss.netty.handler.codec.http.HttpRequest;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostBodyUtil.SeekAheadNoBackArrayException;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostBodyUtil.SeekAheadOptimize;
|
||||
import org.jboss.netty.handler.codec.http.multipart.HttpPostBodyUtil.TransferEncodingMechanism;
|
||||
import org.jboss.netty.util.internal.CaseIgnoringComparator;
|
||||
|
||||
/**
|
||||
* This decoder will decode Body and can handle POST BODY.
|
||||
@ -126,7 +132,7 @@ public class HttpPostRequestDecoder {
|
||||
public HttpPostRequestDecoder(HttpRequest request)
|
||||
throws ErrorDataDecoderException, IncompatibleDataDecoderException {
|
||||
this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE),
|
||||
request, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
request, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,7 +145,7 @@ public class HttpPostRequestDecoder {
|
||||
*/
|
||||
public HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request)
|
||||
throws ErrorDataDecoderException, IncompatibleDataDecoderException {
|
||||
this(factory, request, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
this(factory, request, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -471,11 +477,11 @@ public class HttpPostRequestDecoder {
|
||||
setFinalBuffer(undecodedChunk.slice(firstpos, ampersandpos - firstpos));
|
||||
firstpos = currentpos;
|
||||
contRead = true;
|
||||
} else if (read == HttpCodecUtil.CR) {
|
||||
} else if (read == HttpConstants.CR) {
|
||||
if (undecodedChunk.readable()) {
|
||||
read = (char) undecodedChunk.readUnsignedByte();
|
||||
currentpos++;
|
||||
if (read == HttpCodecUtil.LF) {
|
||||
if (read == HttpConstants.LF) {
|
||||
currentStatus = MultiPartStatus.PREEPILOGUE;
|
||||
ampersandpos = currentpos - 2;
|
||||
setFinalBuffer(
|
||||
@ -490,7 +496,7 @@ public class HttpPostRequestDecoder {
|
||||
} else {
|
||||
currentpos--;
|
||||
}
|
||||
} else if (read == HttpCodecUtil.LF) {
|
||||
} else if (read == HttpConstants.LF) {
|
||||
currentStatus = MultiPartStatus.PREEPILOGUE;
|
||||
ampersandpos = currentpos - 1;
|
||||
setFinalBuffer(
|
||||
@ -597,11 +603,11 @@ public class HttpPostRequestDecoder {
|
||||
setFinalBuffer(undecodedChunk.slice(firstpos, ampersandpos - firstpos));
|
||||
firstpos = currentpos;
|
||||
contRead = true;
|
||||
} else if (read == HttpCodecUtil.CR) {
|
||||
} else if (read == HttpConstants.CR) {
|
||||
if (sao.pos < sao.limit) {
|
||||
read = (char) (sao.bytes[sao.pos ++] & 0xFF);
|
||||
currentpos++;
|
||||
if (read == HttpCodecUtil.LF) {
|
||||
if (read == HttpConstants.LF) {
|
||||
currentStatus = MultiPartStatus.PREEPILOGUE;
|
||||
ampersandpos = currentpos - 2;
|
||||
sao.setReadPosition(0);
|
||||
@ -621,7 +627,7 @@ public class HttpPostRequestDecoder {
|
||||
currentpos --;
|
||||
}
|
||||
}
|
||||
} else if (read == HttpCodecUtil.LF) {
|
||||
} else if (read == HttpConstants.LF) {
|
||||
currentStatus = MultiPartStatus.PREEPILOGUE;
|
||||
ampersandpos = currentpos - 1;
|
||||
sao.setReadPosition(0);
|
||||
@ -1212,12 +1218,12 @@ public class HttpPostRequestDecoder {
|
||||
StringBuilder sb = new StringBuilder(64);
|
||||
while (undecodedChunk.readable()) {
|
||||
byte nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
return sb.toString();
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
return sb.toString();
|
||||
} else {
|
||||
sb.append((char) nextByte);
|
||||
@ -1248,17 +1254,17 @@ public class HttpPostRequestDecoder {
|
||||
StringBuilder sb = new StringBuilder(64);
|
||||
while (sao.pos < sao.limit) {
|
||||
byte nextByte = sao.bytes[sao.pos ++];
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (sao.pos < sao.limit) {
|
||||
nextByte = sao.bytes[sao.pos ++];
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
sao.setReadPosition(0);
|
||||
return sb.toString();
|
||||
}
|
||||
} else {
|
||||
sb.append((char) nextByte);
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
sao.setReadPosition(0);
|
||||
return sb.toString();
|
||||
} else {
|
||||
@ -1304,16 +1310,16 @@ public class HttpPostRequestDecoder {
|
||||
newLine = false;
|
||||
index = 0;
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (undecodedChunk.readable()) {
|
||||
nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 2;
|
||||
}
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 1;
|
||||
@ -1324,16 +1330,16 @@ public class HttpPostRequestDecoder {
|
||||
}
|
||||
} else {
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (undecodedChunk.readable()) {
|
||||
nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 2;
|
||||
}
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 1;
|
||||
@ -1407,10 +1413,10 @@ public class HttpPostRequestDecoder {
|
||||
newLine = false;
|
||||
index = 0;
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (sao.pos < sao.limit) {
|
||||
nextByte = sao.bytes[sao.pos ++];
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1421,7 +1427,7 @@ public class HttpPostRequestDecoder {
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1434,10 +1440,10 @@ public class HttpPostRequestDecoder {
|
||||
}
|
||||
} else {
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (sao.pos < sao.limit) {
|
||||
nextByte = sao.bytes[sao.pos ++];
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1448,7 +1454,7 @@ public class HttpPostRequestDecoder {
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1512,16 +1518,16 @@ public class HttpPostRequestDecoder {
|
||||
newLine = false;
|
||||
index = 0;
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (undecodedChunk.readable()) {
|
||||
nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 2;
|
||||
}
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 1;
|
||||
@ -1531,16 +1537,16 @@ public class HttpPostRequestDecoder {
|
||||
}
|
||||
} else {
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (undecodedChunk.readable()) {
|
||||
nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 2;
|
||||
}
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 1;
|
||||
@ -1616,10 +1622,10 @@ public class HttpPostRequestDecoder {
|
||||
newLine = false;
|
||||
index = 0;
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (sao.pos < sao.limit) {
|
||||
nextByte = sao.bytes[sao.pos ++];
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1629,7 +1635,7 @@ public class HttpPostRequestDecoder {
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1641,10 +1647,10 @@ public class HttpPostRequestDecoder {
|
||||
}
|
||||
} else {
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (sao.pos < sao.limit) {
|
||||
nextByte = sao.bytes[sao.pos ++];
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1654,7 +1660,7 @@ public class HttpPostRequestDecoder {
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1701,17 +1707,17 @@ public class HttpPostRequestDecoder {
|
||||
int i = 0;
|
||||
for (i = 0; i < field.length(); i ++) {
|
||||
char nextChar = field.charAt(i);
|
||||
if (nextChar == HttpCodecUtil.COLON) {
|
||||
sb.append(HttpCodecUtil.SP);
|
||||
} else if (nextChar == HttpCodecUtil.COMMA) {
|
||||
sb.append(HttpCodecUtil.SP);
|
||||
} else if (nextChar == HttpCodecUtil.EQUALS) {
|
||||
sb.append(HttpCodecUtil.SP);
|
||||
} else if (nextChar == HttpCodecUtil.SEMICOLON) {
|
||||
sb.append(HttpCodecUtil.SP);
|
||||
} else if (nextChar == HttpCodecUtil.HT) {
|
||||
sb.append(HttpCodecUtil.SP);
|
||||
} else if (nextChar == HttpCodecUtil.DOUBLE_QUOTE) {
|
||||
if (nextChar == HttpConstants.COLON) {
|
||||
sb.append(HttpConstants.SP);
|
||||
} else if (nextChar == HttpConstants.COMMA) {
|
||||
sb.append(HttpConstants.SP);
|
||||
} else if (nextChar == HttpConstants.EQUALS) {
|
||||
sb.append(HttpConstants.SP);
|
||||
} else if (nextChar == HttpConstants.SEMICOLON) {
|
||||
sb.append(HttpConstants.SP);
|
||||
} else if (nextChar == HttpConstants.HT) {
|
||||
sb.append(HttpConstants.SP);
|
||||
} else if (nextChar == HttpConstants.DOUBLE_QUOTE) {
|
||||
// nothing added, just removes it
|
||||
} else {
|
||||
sb.append(nextChar);
|
||||
@ -1729,18 +1735,18 @@ public class HttpPostRequestDecoder {
|
||||
return false;
|
||||
}
|
||||
byte nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (!undecodedChunk.readable()) {
|
||||
undecodedChunk.readerIndex(undecodedChunk.readerIndex() - 1);
|
||||
return false;
|
||||
}
|
||||
nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
return true;
|
||||
}
|
||||
undecodedChunk.readerIndex(undecodedChunk.readerIndex() - 2);
|
||||
return false;
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
return true;
|
||||
}
|
||||
undecodedChunk.readerIndex(undecodedChunk.readerIndex() - 1);
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -27,6 +27,12 @@ import java.util.Random;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.handler.codec.http.DefaultHttpChunk;
|
||||
import org.jboss.netty.handler.codec.http.HttpChunk;
|
||||
import org.jboss.netty.handler.codec.http.HttpConstants;
|
||||
import org.jboss.netty.handler.codec.http.HttpHeaders;
|
||||
import org.jboss.netty.handler.codec.http.HttpMethod;
|
||||
import org.jboss.netty.handler.codec.http.HttpRequest;
|
||||
import org.jboss.netty.handler.stream.ChunkedInput;
|
||||
|
||||
/**
|
||||
@ -92,7 +98,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
||||
public HttpPostRequestEncoder(HttpRequest request, boolean multipart)
|
||||
throws ErrorDataEncoderException {
|
||||
this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE),
|
||||
request, multipart, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
request, multipart, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,7 +111,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
||||
*/
|
||||
public HttpPostRequestEncoder(HttpDataFactory factory, HttpRequest request, boolean multipart)
|
||||
throws ErrorDataEncoderException {
|
||||
this(factory, request, multipart, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
this(factory, request, multipart, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
/**
|
||||
* Interface for all Objects that could be encoded/decoded using HttpPostRequestEncoder/Decoder
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -13,12 +13,13 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.handler.codec.http.HttpConstants;
|
||||
|
||||
/**
|
||||
* Memory implementation of Attributes
|
||||
@ -26,7 +27,7 @@ import org.jboss.netty.buffer.ChannelBuffers;
|
||||
public class MemoryAttribute extends AbstractMemoryHttpData implements Attribute {
|
||||
|
||||
public MemoryAttribute(String name) {
|
||||
super(name, HttpCodecUtil.DEFAULT_CHARSET, 0);
|
||||
super(name, HttpConstants.DEFAULT_CHARSET, 0);
|
||||
}
|
||||
/**
|
||||
*
|
||||
@ -37,7 +38,7 @@ public class MemoryAttribute extends AbstractMemoryHttpData implements Attribute
|
||||
* @throws IOException
|
||||
*/
|
||||
public MemoryAttribute(String name, String value) throws IOException {
|
||||
super(name, HttpCodecUtil.DEFAULT_CHARSET, 0); // Attribute have no default size
|
||||
super(name, HttpConstants.DEFAULT_CHARSET, 0); // Attribute have no default size
|
||||
setValue(value);
|
||||
}
|
||||
|
@ -13,10 +13,12 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.jboss.netty.handler.codec.http.HttpHeaders;
|
||||
|
||||
/**
|
||||
* Default FileUpload implementation that stores file into memory.<br><br>
|
||||
*
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -28,7 +28,7 @@ import org.jboss.netty.buffer.ChannelBuffer;
|
||||
public class MixedAttribute implements Attribute {
|
||||
private Attribute attribute;
|
||||
|
||||
private long limitSize;
|
||||
private final long limitSize;
|
||||
|
||||
public MixedAttribute(String name, long limitSize) {
|
||||
this.limitSize = limitSize;
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -28,9 +28,9 @@ import org.jboss.netty.buffer.ChannelBuffer;
|
||||
public class MixedFileUpload implements FileUpload {
|
||||
private FileUpload fileUpload;
|
||||
|
||||
private long limitSize;
|
||||
private final long limitSize;
|
||||
|
||||
private long definedSize;
|
||||
private final long definedSize;
|
||||
|
||||
public MixedFileUpload(String name, String filename, String contentType,
|
||||
String contentTransferEncoding, Charset charset, long size,
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2011 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* HTTP multipart support.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http.multipart;
|
@ -119,7 +119,7 @@ public class CloseWebSocketFrame extends WebSocketFrame {
|
||||
* a status code is set, -1 is returned.
|
||||
*/
|
||||
public int getStatusCode() {
|
||||
ChannelBuffer binaryData = this.getBinaryData();
|
||||
ChannelBuffer binaryData = getBinaryData();
|
||||
if (binaryData == null || binaryData.capacity() == 0) {
|
||||
return -1;
|
||||
}
|
||||
@ -136,7 +136,7 @@ public class CloseWebSocketFrame extends WebSocketFrame {
|
||||
* text is not supplied, an empty string is returned.
|
||||
*/
|
||||
public String getReasonText() {
|
||||
ChannelBuffer binaryData = this.getBinaryData();
|
||||
ChannelBuffer binaryData = getBinaryData();
|
||||
if (binaryData == null || binaryData.capacity() <= 2) {
|
||||
return "";
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ package org.jboss.netty.handler.codec.http.websocketx;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
|
||||
|
||||
/**
|
||||
|
@ -78,7 +78,7 @@ public abstract class WebSocketClientHandshaker {
|
||||
Map<String, String> customHeaders, long maxFramePayloadLength) {
|
||||
this.webSocketUrl = webSocketUrl;
|
||||
this.version = version;
|
||||
this.expectedSubprotocol = subprotocol;
|
||||
expectedSubprotocol = subprotocol;
|
||||
this.customHeaders = customHeaders;
|
||||
this.maxFramePayloadLength = maxFramePayloadLength;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
|
||||
// See https://github.com/netty/netty/issues/264
|
||||
request.addHeader(Names.SEC_WEBSOCKET_ORIGIN, originValue);
|
||||
|
||||
String expectedSubprotocol = this.getExpectedSubprotocol();
|
||||
String expectedSubprotocol = getExpectedSubprotocol();
|
||||
if (expectedSubprotocol != null && !expectedSubprotocol.equals("")) {
|
||||
request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
|
||||
}
|
||||
@ -232,7 +232,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
|
||||
setHandshakeComplete();
|
||||
|
||||
channel.getPipeline().get(HttpResponseDecoder.class).replace("ws-decoder",
|
||||
new WebSocket08FrameDecoder(false, allowExtensions, this.getMaxFramePayloadLength()));
|
||||
new WebSocket08FrameDecoder(false, allowExtensions, getMaxFramePayloadLength()));
|
||||
|
||||
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
|
||||
}
|
||||
request.addHeader(Names.ORIGIN, originValue);
|
||||
|
||||
String expectedSubprotocol = this.getExpectedSubprotocol();
|
||||
String expectedSubprotocol = getExpectedSubprotocol();
|
||||
if (expectedSubprotocol != null && !expectedSubprotocol.equals("")) {
|
||||
request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
|
||||
}
|
||||
@ -227,7 +227,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
|
||||
setHandshakeComplete();
|
||||
|
||||
channel.getPipeline().get(HttpResponseDecoder.class).replace("ws-decoder",
|
||||
new WebSocket13FrameDecoder(false, allowExtensions, this.getMaxFramePayloadLength()));
|
||||
new WebSocket13FrameDecoder(false, allowExtensions, getMaxFramePayloadLength()));
|
||||
|
||||
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public abstract class WebSocketServerHandshaker {
|
||||
*/
|
||||
public Set<String> getSubprotocols() {
|
||||
Set<String> ret = new LinkedHashSet<String>();
|
||||
for (String p : this.subprotocols) {
|
||||
for (String p : subprotocols) {
|
||||
ret.add(p);
|
||||
}
|
||||
return ret;
|
||||
|
@ -158,7 +158,7 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
|
||||
throw new WebSocketHandshakeException("Requested subprotocol(s) not supported: " + subprotocols);
|
||||
} else {
|
||||
res.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, selectedSubprotocol);
|
||||
this.setSelectedSubprotocol(selectedSubprotocol);
|
||||
setSelectedSubprotocol(selectedSubprotocol);
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
|
||||
p.remove(HttpChunkAggregator.class);
|
||||
}
|
||||
p.replace(HttpRequestDecoder.class, "wsdecoder",
|
||||
new WebSocket00FrameDecoder(this.getMaxFramePayloadLength()));
|
||||
new WebSocket00FrameDecoder(getMaxFramePayloadLength()));
|
||||
|
||||
ChannelFuture future = channel.write(res);
|
||||
|
||||
|
@ -163,7 +163,7 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker {
|
||||
throw new WebSocketHandshakeException("Requested subprotocol(s) not supported: " + subprotocols);
|
||||
} else {
|
||||
res.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, selectedSubprotocol);
|
||||
this.setSelectedSubprotocol(selectedSubprotocol);
|
||||
setSelectedSubprotocol(selectedSubprotocol);
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker {
|
||||
}
|
||||
|
||||
p.replace(HttpRequestDecoder.class, "wsdecoder",
|
||||
new WebSocket08FrameDecoder(true, allowExtensions, this.getMaxFramePayloadLength()));
|
||||
new WebSocket08FrameDecoder(true, allowExtensions, getMaxFramePayloadLength()));
|
||||
p.replace(HttpResponseEncoder.class, "wsencoder", new WebSocket08FrameEncoder(false));
|
||||
|
||||
return future;
|
||||
|
@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http.websocketx;
|
||||
|
||||
import static org.jboss.netty.handler.codec.http.HttpHeaders.Values.WEBSOCKET;
|
||||
import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1;
|
||||
import static org.jboss.netty.handler.codec.http.HttpHeaders.Values.*;
|
||||
import static org.jboss.netty.handler.codec.http.HttpVersion.*;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
@ -25,14 +25,14 @@ import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelFutureListener;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
|
||||
import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
|
||||
import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
|
||||
import org.jboss.netty.handler.codec.http.HttpHeaders.Names;
|
||||
import org.jboss.netty.handler.codec.http.HttpRequest;
|
||||
import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
|
||||
import org.jboss.netty.handler.codec.http.HttpResponse;
|
||||
import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
|
||||
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
|
||||
import org.jboss.netty.handler.codec.http.HttpHeaders.Names;
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
import org.jboss.netty.util.CharsetUtil;
|
||||
@ -170,7 +170,7 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker {
|
||||
throw new WebSocketHandshakeException("Requested subprotocol(s) not supported: " + subprotocols);
|
||||
} else {
|
||||
res.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, selectedSubprotocol);
|
||||
this.setSelectedSubprotocol(selectedSubprotocol);
|
||||
setSelectedSubprotocol(selectedSubprotocol);
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker {
|
||||
}
|
||||
|
||||
p.replace(HttpRequestDecoder.class, "wsdecoder",
|
||||
new WebSocket13FrameDecoder(true, allowExtensions, this.getMaxFramePayloadLength()));
|
||||
new WebSocket13FrameDecoder(true, allowExtensions, getMaxFramePayloadLength()));
|
||||
p.replace(HttpResponseEncoder.class, "wsencoder", new WebSocket13FrameEncoder(false));
|
||||
|
||||
return future;
|
||||
|
@ -17,11 +17,11 @@ package org.jboss.netty.handler.codec.http.websocketx;
|
||||
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
|
||||
import org.jboss.netty.handler.codec.http.HttpHeaders.Names;
|
||||
import org.jboss.netty.handler.codec.http.HttpRequest;
|
||||
import org.jboss.netty.handler.codec.http.HttpResponse;
|
||||
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
|
||||
import org.jboss.netty.handler.codec.http.HttpVersion;
|
||||
import org.jboss.netty.handler.codec.http.HttpHeaders.Names;
|
||||
|
||||
/**
|
||||
* Instances the appropriate handshake class to use for servers
|
||||
|
@ -17,8 +17,8 @@ package org.jboss.netty.handler.codec.marshalling;
|
||||
|
||||
import org.jboss.marshalling.Marshaller;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
|
||||
|
||||
/**
|
||||
|
@ -18,8 +18,8 @@ package org.jboss.netty.handler.codec.marshalling;
|
||||
import org.jboss.marshalling.Marshaller;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
|
||||
|
||||
/**
|
||||
|
@ -19,10 +19,10 @@ import static org.jboss.netty.buffer.ChannelBuffers.*;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
|
||||
import org.jboss.netty.handler.codec.frame.LengthFieldPrepender;
|
||||
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
|
||||
|
@ -20,8 +20,8 @@ import static org.jboss.netty.buffer.ChannelBuffers.*;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBufferOutputStream;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
|
||||
|
||||
import com.google.protobuf.CodedOutputStream;
|
||||
|
@ -423,7 +423,7 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
|
||||
if (cumulation == null) {
|
||||
// the cumulation buffer is not created yet so just pass the input
|
||||
// to callDecode(...) method
|
||||
this.cumulation = input;
|
||||
cumulation = input;
|
||||
replayable = new ReplayingDecoderBuffer(input);
|
||||
|
||||
int oldReaderIndex = input.readerIndex();
|
||||
@ -461,7 +461,7 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
|
||||
}
|
||||
replayable = new ReplayingDecoderBuffer(cumulation);
|
||||
} else {
|
||||
this.cumulation = null;
|
||||
cumulation = null;
|
||||
replayable = ReplayingDecoderBuffer.EMPTY_BUFFER;
|
||||
}
|
||||
}
|
||||
@ -489,12 +489,12 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
|
||||
ChannelBuffer buf;
|
||||
if (fit) {
|
||||
// the input fit in the cumulation buffer so copy it over
|
||||
buf = this.cumulation;
|
||||
buf = cumulation;
|
||||
buf.writeBytes(input);
|
||||
} else {
|
||||
// wrap the cumulation and input
|
||||
buf = ChannelBuffers.wrappedBuffer(cumulation, input);
|
||||
this.cumulation = buf;
|
||||
cumulation = buf;
|
||||
replayable = new ReplayingDecoderBuffer(cumulation);
|
||||
}
|
||||
|
||||
@ -506,13 +506,13 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
|
||||
} finally {
|
||||
if (!buf.readable()) {
|
||||
// nothing readable left so reset the state
|
||||
this.cumulation = null;
|
||||
cumulation = null;
|
||||
replayable = ReplayingDecoderBuffer.EMPTY_BUFFER;
|
||||
} else {
|
||||
// create a new buffer and copy the readable buffer into it
|
||||
this.cumulation = newCumulationBuffer(ctx, buf.readableBytes());
|
||||
this.cumulation.writeBytes(buf);
|
||||
replayable = new ReplayingDecoderBuffer(this.cumulation);
|
||||
cumulation = newCumulationBuffer(ctx, buf.readableBytes());
|
||||
cumulation.writeBytes(buf);
|
||||
replayable = new ReplayingDecoderBuffer(cumulation);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ package org.jboss.netty.handler.codec.rtsp;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.handler.codec.http.HttpMessage;
|
||||
import org.jboss.netty.handler.codec.http.HttpMessageEncoder;
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class ObjectDecoderInputStream extends InputStream implements
|
||||
} else {
|
||||
this.in = new DataInputStream(in);
|
||||
}
|
||||
this.classResolver = ClassResolvers.weakCachingResolver(classLoader);
|
||||
classResolver = ClassResolvers.weakCachingResolver(classLoader);
|
||||
this.maxObjectSize = maxObjectSize;
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ import java.io.ObjectOutputStream;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBufferOutputStream;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
|
||||
|
||||
/**
|
||||
|
@ -40,7 +40,7 @@ public class DefaultSpdyHeaderBlock implements SpdyHeaderBlock {
|
||||
}
|
||||
|
||||
public void setInvalid() {
|
||||
this.invalid = true;
|
||||
invalid = true;
|
||||
}
|
||||
|
||||
public void addHeader(final String name, final Object value) {
|
||||
|
@ -410,7 +410,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
||||
return new DefaultSpdyPingFrame(ID);
|
||||
|
||||
case SPDY_GOAWAY_FRAME:
|
||||
int minLength = (version < 3) ? 4 : 8;
|
||||
int minLength = version < 3 ? 4 : 8;
|
||||
if (buffer.readableBytes() < minLength) {
|
||||
return null;
|
||||
}
|
||||
@ -448,7 +448,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
||||
int streamID;
|
||||
switch (type) {
|
||||
case SPDY_SYN_STREAM_FRAME:
|
||||
minLength = (version < 3) ? 12 : 10;
|
||||
minLength = version < 3 ? 12 : 10;
|
||||
if (buffer.readableBytes() < minLength) {
|
||||
return null;
|
||||
}
|
||||
@ -477,7 +477,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
||||
return spdySynStreamFrame;
|
||||
|
||||
case SPDY_SYN_REPLY_FRAME:
|
||||
minLength = (version < 3) ? 8 : 4;
|
||||
minLength = version < 3 ? 8 : 4;
|
||||
if (buffer.readableBytes() < minLength) {
|
||||
return null;
|
||||
}
|
||||
@ -575,7 +575,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
||||
return;
|
||||
}
|
||||
|
||||
int lengthFieldSize = (version < 3) ? 2 : 4;
|
||||
int lengthFieldSize = version < 3 ? 2 : 4;
|
||||
|
||||
if (numHeaders == -1) {
|
||||
// Read number of Name/Value pairs
|
||||
@ -690,10 +690,10 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
||||
private boolean isValidControlFrameHeader() {
|
||||
switch (type) {
|
||||
case SPDY_SYN_STREAM_FRAME:
|
||||
return (version < 3) ? length >= 12 : length >= 10;
|
||||
return version < 3 ? length >= 12 : length >= 10;
|
||||
|
||||
case SPDY_SYN_REPLY_FRAME:
|
||||
return (version < 3) ? length >= 8 : length >= 4;
|
||||
return version < 3 ? length >= 8 : length >= 4;
|
||||
|
||||
case SPDY_RST_STREAM_FRAME:
|
||||
return flags == 0 && length == 8;
|
||||
@ -708,7 +708,7 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
||||
return length == 4;
|
||||
|
||||
case SPDY_GOAWAY_FRAME:
|
||||
return (version < 3) ? length == 4 : length == 8;
|
||||
return version < 3 ? length == 4 : length == 8;
|
||||
|
||||
case SPDY_HEADERS_FRAME:
|
||||
if (version < 3) {
|
||||
|
@ -128,7 +128,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
|
||||
int headerBlockLength = data.readableBytes();
|
||||
int length;
|
||||
if (version < 3) {
|
||||
length = (headerBlockLength == 0) ? 12 : 10 + headerBlockLength;
|
||||
length = headerBlockLength == 0 ? 12 : 10 + headerBlockLength;
|
||||
} else {
|
||||
length = 10 + headerBlockLength;
|
||||
}
|
||||
@ -164,7 +164,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
|
||||
int headerBlockLength = data.readableBytes();
|
||||
int length;
|
||||
if (version < 3) {
|
||||
length = (headerBlockLength == 0) ? 8 : 6 + headerBlockLength;
|
||||
length = headerBlockLength == 0 ? 8 : 6 + headerBlockLength;
|
||||
} else {
|
||||
length = 4 + headerBlockLength;
|
||||
}
|
||||
@ -259,7 +259,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
|
||||
} else if (msg instanceof SpdyGoAwayFrame) {
|
||||
|
||||
SpdyGoAwayFrame spdyGoAwayFrame = (SpdyGoAwayFrame) msg;
|
||||
int length = (version < 3) ? 4 : 8;
|
||||
int length = version < 3 ? 4 : 8;
|
||||
ChannelBuffer frame = ChannelBuffers.buffer(
|
||||
ByteOrder.BIG_ENDIAN, SPDY_HEADER_SIZE + length);
|
||||
frame.writeShort(version | 0x8000);
|
||||
@ -280,7 +280,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
|
||||
int headerBlockLength = data.readableBytes();
|
||||
int length;
|
||||
if (version < 3) {
|
||||
length = (headerBlockLength == 0) ? 4 : 6 + headerBlockLength;
|
||||
length = headerBlockLength == 0 ? 4 : 6 + headerBlockLength;
|
||||
} else {
|
||||
length = 4 + headerBlockLength;
|
||||
}
|
||||
|
@ -15,12 +15,12 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.spdy;
|
||||
|
||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
|
||||
import java.util.zip.Deflater;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
|
||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
|
||||
class SpdyHeaderBlockZlibCompressor extends SpdyHeaderBlockCompressor {
|
||||
|
||||
private final byte[] out = new byte[8192];
|
||||
|
@ -15,13 +15,13 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.spdy;
|
||||
|
||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
|
||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
|
||||
class SpdyHeaderBlockZlibDecompressor extends SpdyHeaderBlockDecompressor {
|
||||
|
||||
private final int version;
|
||||
|
@ -18,7 +18,6 @@ package org.jboss.netty.handler.codec.spdy;
|
||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
@ -104,7 +103,7 @@ public class SpdyHttpDecoder extends OneToOneDecoder {
|
||||
Channels.write(ctx, Channels.future(channel), spdyRstStreamFrame);
|
||||
}
|
||||
|
||||
String URL = SpdyHeaders.getUrl(spdySynStreamFrame);
|
||||
String URL = SpdyHeaders.getUrl(spdyVersion, spdySynStreamFrame);
|
||||
|
||||
// If a client receives a SYN_STREAM without a 'url' header
|
||||
// it must reply with a RST_STREAM with error code PROTOCOL_ERROR
|
||||
|
@ -128,12 +128,12 @@ final class SpdySession {
|
||||
|
||||
public int getSendWindowSize(int streamID) {
|
||||
StreamState state = activeStreams.get(new Integer(streamID));
|
||||
return (state != null) ? state.getSendWindowSize() : -1;
|
||||
return state != null ? state.getSendWindowSize() : -1;
|
||||
}
|
||||
|
||||
public int updateSendWindowSize(int streamID, int deltaWindowSize) {
|
||||
StreamState state = activeStreams.get(new Integer(streamID));
|
||||
return (state != null) ? state.updateSendWindowSize(deltaWindowSize) : -1;
|
||||
return state != null ? state.updateSendWindowSize(deltaWindowSize) : -1;
|
||||
}
|
||||
|
||||
public int updateReceiveWindowSize(int streamID, int deltaWindowSize) {
|
||||
@ -141,12 +141,12 @@ final class SpdySession {
|
||||
if (deltaWindowSize > 0) {
|
||||
state.setReceiveWindowSizeLowerBound(0);
|
||||
}
|
||||
return (state != null) ? state.updateReceiveWindowSize(deltaWindowSize) : -1;
|
||||
return state != null ? state.updateReceiveWindowSize(deltaWindowSize) : -1;
|
||||
}
|
||||
|
||||
public int getReceiveWindowSizeLowerBound(int streamID) {
|
||||
StreamState state = activeStreams.get(new Integer(streamID));
|
||||
return (state != null) ? state.getReceiveWindowSizeLowerBound() : 0;
|
||||
return state != null ? state.getReceiveWindowSizeLowerBound() : 0;
|
||||
}
|
||||
|
||||
public void updateAllReceiveWindowSizes(int deltaWindowSize) {
|
||||
@ -165,12 +165,12 @@ final class SpdySession {
|
||||
|
||||
public MessageEvent getPendingWrite(int streamID) {
|
||||
StreamState state = activeStreams.get(new Integer(streamID));
|
||||
return (state != null) ? state.getPendingWrite() : null;
|
||||
return state != null ? state.getPendingWrite() : null;
|
||||
}
|
||||
|
||||
public MessageEvent removePendingWrite(int streamID) {
|
||||
StreamState state = activeStreams.get(new Integer(streamID));
|
||||
return (state != null) ? state.removePendingWrite() : null;
|
||||
return state != null ? state.removePendingWrite() : null;
|
||||
}
|
||||
|
||||
private static final class StreamState {
|
||||
@ -179,10 +179,10 @@ final class SpdySession {
|
||||
private volatile boolean remoteSideClosed;
|
||||
private volatile boolean localSideClosed;
|
||||
private boolean receivedReply;
|
||||
private AtomicInteger sendWindowSize;
|
||||
private AtomicInteger receiveWindowSize;
|
||||
private final AtomicInteger sendWindowSize;
|
||||
private final AtomicInteger receiveWindowSize;
|
||||
private volatile int receiveWindowSizeLowerBound;
|
||||
private ConcurrentLinkedQueue<MessageEvent> pendingWriteQueue =
|
||||
private final ConcurrentLinkedQueue<MessageEvent> pendingWriteQueue =
|
||||
new ConcurrentLinkedQueue<MessageEvent>();
|
||||
|
||||
public StreamState(
|
||||
|
@ -93,7 +93,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
||||
"unsupported version: " + version);
|
||||
}
|
||||
this.server = server;
|
||||
this.flowControl = version >= 3;
|
||||
flowControl = version >= 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,10 +19,10 @@ import java.nio.charset.Charset;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
|
||||
import org.jboss.netty.handler.codec.frame.Delimiters;
|
||||
import org.jboss.netty.handler.codec.frame.FrameDecoder;
|
||||
|
@ -21,10 +21,10 @@ import java.nio.charset.Charset;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.ChannelHandler.Sharable;
|
||||
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
|
||||
import org.jboss.netty.handler.codec.frame.Delimiters;
|
||||
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
|
||||
|
@ -15,18 +15,18 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.execution;
|
||||
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelEvent;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelFutureListener;
|
||||
import org.jboss.netty.util.ObjectSizeEstimator;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelEvent;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelFutureListener;
|
||||
import org.jboss.netty.util.ObjectSizeEstimator;
|
||||
|
||||
/**
|
||||
* {@link Executor} which should be used for downstream {@link ChannelEvent}'s. This implementation will take care of preserve the order of the events in a {@link Channel}.
|
||||
* If you don't need to preserve the order just use one of the {@link Executor} implementations provided by the static methods of {@link Executors}.
|
||||
|
@ -141,7 +141,7 @@ public abstract class CIDR implements Comparable<CIDR> {
|
||||
if (!(arg0 instanceof CIDR)) {
|
||||
return false;
|
||||
}
|
||||
return this.compareTo((CIDR) arg0) == 0;
|
||||
return compareTo((CIDR) arg0) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,6 +53,7 @@ public class CIDR6 extends CIDR {
|
||||
addressEndBigInt = addressBigInt.add(ipv6CidrMaskToBaseAddress(cidrMask)).subtract(BigInteger.ONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetAddress getEndAddress() {
|
||||
try {
|
||||
return bigIntToIPv6Address(addressEndBigInt);
|
||||
|
@ -157,7 +157,7 @@ public abstract class IpFilteringHandlerImpl implements ChannelUpstreamHandler,
|
||||
|
||||
|
||||
public void removeIpFilterListener() {
|
||||
this.listener = null;
|
||||
listener = null;
|
||||
|
||||
}
|
||||
|
||||
|
@ -15,11 +15,12 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.ipfilter;
|
||||
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
|
||||
/**
|
||||
* This class allows to check if an IP V4 or V6 Address is contained in a subnet.<BR>
|
||||
* <p/>
|
||||
@ -59,7 +60,7 @@ public class IpSubnet implements IpSet, Comparable<IpSubnet> {
|
||||
InternalLoggerFactory.getInstance(IpSubnet.class);
|
||||
|
||||
/** Internal representation */
|
||||
private CIDR cidr;
|
||||
private final CIDR cidr;
|
||||
|
||||
/** Create IpSubnet for ALL (used for ALLOW or DENY ALL) */
|
||||
public IpSubnet() {
|
||||
@ -141,26 +142,4 @@ public class IpSubnet implements IpSet, Comparable<IpSubnet> {
|
||||
public int compareTo(IpSubnet o) {
|
||||
return cidr.toString().compareTo(o.cidr.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple test functions
|
||||
*
|
||||
* @param args where args[0] is the netmask (standard or CIDR notation) and optional args[1] is
|
||||
* the inetAddress to test with this IpSubnet
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length != 0) {
|
||||
IpSubnet ipSubnet = null;
|
||||
try {
|
||||
ipSubnet = new IpSubnet(args[0]);
|
||||
} catch (UnknownHostException e) {
|
||||
return;
|
||||
}
|
||||
logger.debug("IpSubnet: " + ipSubnet.toString() + " from " + ipSubnet.cidr.getBaseAddress() + " to "
|
||||
+ ipSubnet.cidr.getEndAddress() + " mask " + ipSubnet.cidr.getMask());
|
||||
if (args.length > 1) {
|
||||
logger.debug("Is IN: " + args[1] + " " + ipSubnet.contains(args[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,13 +15,14 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.ipfilter;
|
||||
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
|
||||
/**
|
||||
* This class allows to check if an IP-V4-Address is contained in a subnet.<BR>
|
||||
* Supported Formats for the Subnets are: 1.1.1.1/255.255.255.255 or 1.1.1.1/32 (CIDR-Notation)
|
||||
@ -141,7 +142,7 @@ public class IpV4Subnet implements IpSet, Comparable<IpV4Subnet> {
|
||||
*
|
||||
* @return the integer representation
|
||||
*/
|
||||
private int toInt(InetAddress inetAddress1) {
|
||||
private static int toInt(InetAddress inetAddress1) {
|
||||
byte[] address = inetAddress1.getAddress();
|
||||
int net = 0;
|
||||
for (byte addres : address) {
|
||||
@ -251,24 +252,4 @@ public class IpV4Subnet implements IpSet, Comparable<IpV4Subnet> {
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple test functions
|
||||
*
|
||||
* @param args where args[0] is the netmask (standard or CIDR notation) and optional args[1] is
|
||||
* the inetAddress to test with this IpV4Subnet
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length != 0) {
|
||||
IpV4Subnet ipV4Subnet = null;
|
||||
try {
|
||||
ipV4Subnet = new IpV4Subnet(args[0]);
|
||||
} catch (UnknownHostException e) {
|
||||
return;
|
||||
}
|
||||
if (args.length > 1) {
|
||||
logger.debug("Is IN: " + args[1] + " " + ipV4Subnet.contains(args[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
|
||||
|
||||
private boolean localhost;
|
||||
|
||||
private String pattern;
|
||||
private final String pattern;
|
||||
|
||||
/**
|
||||
* Instantiates a new pattern rule.
|
||||
@ -67,7 +67,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
|
||||
* @param pattern the filter pattern
|
||||
*/
|
||||
public PatternRule(boolean allow, String pattern) {
|
||||
this.isAllowRule = allow;
|
||||
isAllowRule = allow;
|
||||
this.pattern = pattern;
|
||||
parse(pattern);
|
||||
}
|
||||
@ -78,7 +78,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
|
||||
* @return the pattern
|
||||
*/
|
||||
public String getPattern() {
|
||||
return this.pattern;
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public boolean isAllowRule() {
|
||||
@ -120,7 +120,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
|
||||
for (String c : acls) {
|
||||
c = c.trim();
|
||||
if (c.equals("n:localhost")) {
|
||||
this.localhost = true;
|
||||
localhost = true;
|
||||
} else if (c.startsWith("n:")) {
|
||||
name = addRule(name, c.substring(2));
|
||||
} else if (c.startsWith("i:")) {
|
||||
@ -135,7 +135,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
|
||||
}
|
||||
}
|
||||
|
||||
private String addRule(String pattern, String rule) {
|
||||
private static String addRule(String pattern, String rule) {
|
||||
if (rule == null || rule.length() == 0) {
|
||||
return pattern;
|
||||
}
|
||||
@ -149,7 +149,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
private boolean isLocalhost(InetAddress address) {
|
||||
private static boolean isLocalhost(InetAddress address) {
|
||||
try {
|
||||
if (address.equals(InetAddress.getLocalHost())) {
|
||||
return true;
|
||||
@ -183,14 +183,14 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
|
||||
return -1;
|
||||
}
|
||||
PatternRule p = (PatternRule) o;
|
||||
if (p.isAllowRule() && !this.isAllowRule) {
|
||||
if (p.isAllowRule() && !isAllowRule) {
|
||||
return -1;
|
||||
}
|
||||
if (this.pattern == null && p.pattern == null) {
|
||||
if (pattern == null && p.pattern == null) {
|
||||
return 0;
|
||||
}
|
||||
if (this.pattern != null) {
|
||||
return this.pattern.compareTo(p.getPattern());
|
||||
if (pattern != null) {
|
||||
return pattern.compareTo(p.getPattern());
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.DefaultChannelFuture;
|
||||
import org.jboss.netty.channel.DownstreamMessageEvent;
|
||||
import org.jboss.netty.channel.ExceptionEvent;
|
||||
import org.jboss.netty.channel.LifeCycleAwareChannelHandler;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.handler.codec.frame.FrameDecoder;
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
@ -151,8 +150,7 @@ import org.jboss.netty.util.internal.QueueFactory;
|
||||
* @apiviz.uses org.jboss.netty.handler.ssl.SslBufferPool
|
||||
*/
|
||||
public class SslHandler extends FrameDecoder
|
||||
implements ChannelDownstreamHandler,
|
||||
LifeCycleAwareChannelHandler {
|
||||
implements ChannelDownstreamHandler {
|
||||
|
||||
private static final InternalLogger logger =
|
||||
InternalLoggerFactory.getInstance(SslHandler.class);
|
||||
@ -1219,14 +1217,17 @@ public class SslHandler extends FrameDecoder
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeAdd(ChannelHandlerContext ctx) throws Exception {
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterAdd(ChannelHandlerContext ctx) throws Exception {
|
||||
// Unused
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeRemove(ChannelHandlerContext ctx) throws Exception {
|
||||
// Unused
|
||||
}
|
||||
@ -1234,6 +1235,7 @@ public class SslHandler extends FrameDecoder
|
||||
/**
|
||||
* Fail all pending writes which we were not able to flush out
|
||||
*/
|
||||
@Override
|
||||
public void afterRemove(ChannelHandlerContext ctx) throws Exception {
|
||||
|
||||
// there is no need for synchronization here as we do not receive downstream events anymore
|
||||
|
@ -295,7 +295,7 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns
|
||||
|
||||
}
|
||||
|
||||
if (acquired && (!channel.isConnected() || (channel.isWritable() && !queue.isEmpty()))) {
|
||||
if (acquired && (!channel.isConnected() || channel.isWritable() && !queue.isEmpty())) {
|
||||
flush(ctx, fireNow);
|
||||
}
|
||||
}
|
||||
|
@ -347,14 +347,14 @@ public abstract class AbstractTrafficShapingHandler extends
|
||||
* @return the time that should be necessary to wait to respect limit. Can
|
||||
* be negative time
|
||||
*/
|
||||
private long getTimeToWait(long limit, long bytes, long lastTime,
|
||||
private static long getTimeToWait(long limit, long bytes, long lastTime,
|
||||
long curtime) {
|
||||
long interval = curtime - lastTime;
|
||||
if (interval == 0) {
|
||||
// Time is too short, so just lets continue
|
||||
return 0;
|
||||
}
|
||||
return ((bytes * 1000 / limit - interval) / 10) * 10;
|
||||
return (bytes * 1000 / limit - interval) / 10 * 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -245,7 +245,7 @@ public class TrafficCounter {
|
||||
* @param newcheckInterval
|
||||
*/
|
||||
public void configure(long newcheckInterval) {
|
||||
long newInterval = (newcheckInterval / 10) * 10;
|
||||
long newInterval = newcheckInterval / 10 * 10;
|
||||
if (checkInterval.get() != newInterval) {
|
||||
checkInterval.set(newInterval);
|
||||
if (newInterval <= 0) {
|
||||
|
@ -25,13 +25,13 @@
|
||||
*
|
||||
* <P>Two classes implement this behavior:<br>
|
||||
* <ul>
|
||||
* <li> <tt>{@link TrafficCounter}</tt>: this class implements the counters needed by the handlers.
|
||||
* <li> <tt>{@link org.jboss.netty.handler.traffic.TrafficCounter}</tt>: this class implements the counters needed by the handlers.
|
||||
* It can be accessed to get some extra information like the read or write bytes since last check, the read and write
|
||||
* bandwidth from last check...</li><br><br>
|
||||
*
|
||||
* <li> <tt>{@link AbstractTrafficShapingHandler}</tt>: this abstract class implements the kernel
|
||||
* <li> <tt>{@link org.jboss.netty.handler.traffic.AbstractTrafficShapingHandler}</tt>: this abstract class implements the kernel
|
||||
* of the traffic shaping. It could be extended to fit your needs. Two classes are proposed as default
|
||||
* implementations: see {@link ChannelTrafficShapingHandler} and see {@link GlobalTrafficShapingHandler}
|
||||
* implementations: see {@link org.jboss.netty.handler.traffic.ChannelTrafficShapingHandler} and see {@link org.jboss.netty.handler.traffic.GlobalTrafficShapingHandler}
|
||||
* respectively for Channel traffic shaping and Global traffic shaping.</li><br><br>
|
||||
*
|
||||
* The insertion in the pipeline of one of those handlers can be wherever you want, but
|
||||
@ -62,15 +62,15 @@
|
||||
* [Global or per Channel] [Write or Read] Limitation in byte/s.</li><br>
|
||||
* A value of <tt>0</tt>
|
||||
* stands for no limitation, so the traffic shaping is deactivate (on what you specified).<br>
|
||||
* You can either change those values with the method <tt>configure</tt> in {@link AbstractTrafficShapingHandler}.<br>
|
||||
* You can either change those values with the method <tt>configure</tt> in {@link org.jboss.netty.handler.traffic.AbstractTrafficShapingHandler}.<br>
|
||||
* <br>
|
||||
*
|
||||
* <li>To activate or deactivate the statistics, you can adjust the delay to a low (suggested not less than 200ms
|
||||
* for efficiency reasons) or a high value (let say 24H in millisecond is huge enough to not get the problem)
|
||||
* or even using <tt>0</tt> which means no computation will be done.</li><br>
|
||||
* If you want to do anything with this statistics, just override the <tt>doAccounting</tt> method.<br>
|
||||
* This interval can be changed either from the method <tt>configure</tt> in {@link AbstractTrafficShapingHandler}
|
||||
* or directly using the method <tt>configure</tt> of {@link TrafficCounter}.<br><br>
|
||||
* This interval can be changed either from the method <tt>configure</tt> in {@link org.jboss.netty.handler.traffic.AbstractTrafficShapingHandler}
|
||||
* or directly using the method <tt>configure</tt> of {@link org.jboss.netty.handler.traffic.TrafficCounter}.<br><br>
|
||||
*
|
||||
* </ul></P><br><br>
|
||||
*
|
||||
@ -81,8 +81,8 @@
|
||||
* <tt>pipeline.addLast("XXXXX_TRAFFIC_SHAPING", myHandler);</tt><br>
|
||||
* <tt>...</tt><br>
|
||||
* <tt>pipeline.addLast("MemoryExecutor",new ExecutionHandler(memoryAwareThreadPoolExecutor));</tt><br><br>
|
||||
* <P>Note that a new {@link ChannelTrafficShapingHandler} must be created for each new channel,
|
||||
* but only one {@link GlobalTrafficShapingHandler} must be created for all channels.</P>
|
||||
* <P>Note that a new {@link org.jboss.netty.handler.traffic.ChannelTrafficShapingHandler} must be created for each new channel,
|
||||
* but only one {@link org.jboss.netty.handler.traffic.GlobalTrafficShapingHandler} must be created for all channels.</P>
|
||||
*
|
||||
* <P>Note also that you can create different GlobalTrafficShapingHandler if you want to separate classes of
|
||||
* channels (for instance either from business point of view or from bind address point of view).</P>
|
||||
|
@ -454,7 +454,7 @@ public class HashedWheelTimer implements Timer {
|
||||
//
|
||||
// See https://github.com/netty/netty/issues/356
|
||||
if (DetectionUtil.isWindows()) {
|
||||
sleepTime = (sleepTime / 10) * 10;
|
||||
sleepTime = sleepTime / 10 * 10;
|
||||
}
|
||||
|
||||
if (sleepTime <= 0) {
|
||||
|
@ -13,16 +13,16 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.http;
|
||||
package org.jboss.netty.util.internal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Comparator;
|
||||
|
||||
final class CaseIgnoringComparator implements Comparator<String>, Serializable {
|
||||
public final class CaseIgnoringComparator implements Comparator<String>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4582133183775373862L;
|
||||
|
||||
static final CaseIgnoringComparator INSTANCE = new CaseIgnoringComparator();
|
||||
public static final CaseIgnoringComparator INSTANCE = new CaseIgnoringComparator();
|
||||
|
||||
private CaseIgnoringComparator() {
|
||||
super();
|
@ -22,8 +22,8 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.jboss.netty.channel.ChannelFactory;
|
||||
import org.jboss.netty.channel.ChannelHandler;
|
||||
|
@ -15,21 +15,17 @@
|
||||
*/
|
||||
package org.jboss.netty.channel.local;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.jboss.netty.bootstrap.ClientBootstrap;
|
||||
import org.jboss.netty.bootstrap.ServerBootstrap;
|
||||
import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.ChannelEvent;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelPipeline;
|
||||
import org.jboss.netty.channel.ChannelPipelineFactory;
|
||||
import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
||||
import org.jboss.netty.channel.local.DefaultLocalClientChannelFactory;
|
||||
import org.jboss.netty.channel.local.DefaultLocalServerChannelFactory;
|
||||
import org.jboss.netty.channel.local.LocalAddress;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class LocalAddressTest {
|
||||
private static String LOCAL_ADDR_ID = "test.id";
|
||||
|
@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.jboss.netty.channel.local;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
|
@ -15,16 +15,7 @@
|
||||
*/
|
||||
package org.jboss.netty.channel.socket;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
||||
import org.jboss.netty.channel.socket.DatagramChannelFactory;
|
||||
import org.jboss.netty.util.internal.ExecutorUtil;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@ -33,6 +24,14 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
||||
import org.jboss.netty.util.internal.ExecutorUtil;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -17,7 +17,6 @@ package org.jboss.netty.channel.socket;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.jboss.netty.channel.socket.nio.NioDatagramChannel.ProtocolFamily;
|
||||
import org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory;
|
||||
import org.jboss.netty.channel.socket.oio.OioDatagramChannelFactory;
|
||||
|
||||
@ -25,7 +24,7 @@ public class NioNioDatagramMulticastTest extends AbstractDatagramMulticastTest {
|
||||
|
||||
@Override
|
||||
protected DatagramChannelFactory newServerSocketChannelFactory(Executor executor) {
|
||||
return new NioDatagramChannelFactory(executor, ProtocolFamily.INET);
|
||||
return new NioDatagramChannelFactory(executor, InternetProtocolFamily.IPv4);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user