Remove unnecessarily qualified static access
This commit is contained in:
parent
bbcb035246
commit
58ba0de659
@ -47,25 +47,25 @@ public abstract class AbstractCompositeChannelBufferTest extends
|
||||
protected ByteBuf newBuffer(int length) {
|
||||
buffers = new ArrayList<ByteBuf>();
|
||||
for (int i = 0; i < length + 45; i += 45) {
|
||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
||||
buffers.add(Unpooled.wrappedBuffer(new byte[1]));
|
||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
||||
buffers.add(Unpooled.wrappedBuffer(new byte[2]));
|
||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
||||
buffers.add(Unpooled.wrappedBuffer(new byte[3]));
|
||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
||||
buffers.add(Unpooled.wrappedBuffer(new byte[4]));
|
||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
||||
buffers.add(Unpooled.wrappedBuffer(new byte[5]));
|
||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
||||
buffers.add(Unpooled.wrappedBuffer(new byte[6]));
|
||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
||||
buffers.add(Unpooled.wrappedBuffer(new byte[7]));
|
||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
||||
buffers.add(Unpooled.wrappedBuffer(new byte[8]));
|
||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
||||
buffers.add(Unpooled.wrappedBuffer(new byte[9]));
|
||||
buffers.add(Unpooled.EMPTY_BUFFER);
|
||||
buffers.add(EMPTY_BUFFER);
|
||||
buffers.add(wrappedBuffer(new byte[1]));
|
||||
buffers.add(EMPTY_BUFFER);
|
||||
buffers.add(wrappedBuffer(new byte[2]));
|
||||
buffers.add(EMPTY_BUFFER);
|
||||
buffers.add(wrappedBuffer(new byte[3]));
|
||||
buffers.add(EMPTY_BUFFER);
|
||||
buffers.add(wrappedBuffer(new byte[4]));
|
||||
buffers.add(EMPTY_BUFFER);
|
||||
buffers.add(wrappedBuffer(new byte[5]));
|
||||
buffers.add(EMPTY_BUFFER);
|
||||
buffers.add(wrappedBuffer(new byte[6]));
|
||||
buffers.add(EMPTY_BUFFER);
|
||||
buffers.add(wrappedBuffer(new byte[7]));
|
||||
buffers.add(EMPTY_BUFFER);
|
||||
buffers.add(wrappedBuffer(new byte[8]));
|
||||
buffers.add(EMPTY_BUFFER);
|
||||
buffers.add(wrappedBuffer(new byte[9]));
|
||||
buffers.add(EMPTY_BUFFER);
|
||||
}
|
||||
|
||||
buffer = Unpooled.wrappedBuffer(
|
||||
@ -98,7 +98,7 @@ public abstract class AbstractCompositeChannelBufferTest extends
|
||||
*/
|
||||
@Test
|
||||
public void testComponentAtOffset() {
|
||||
CompositeByteBuf buf = (CompositeByteBuf) Unpooled.wrappedBuffer(new byte[] { 1, 2, 3, 4, 5 }, new byte[] {4, 5, 6, 7, 8, 9, 26});
|
||||
CompositeByteBuf buf = (CompositeByteBuf) wrappedBuffer(new byte[]{1, 2, 3, 4, 5}, new byte[]{4, 5, 6, 7, 8, 9, 26});
|
||||
|
||||
//Ensure that a random place will be fine
|
||||
assertEquals(buf.componentAtOffset(2).capacity(), 5);
|
||||
|
@ -194,13 +194,13 @@ public class ChannelBuffersTest {
|
||||
@Test
|
||||
public void testCompare2() {
|
||||
assertTrue(ByteBufUtil.compare(
|
||||
Unpooled.wrappedBuffer(new byte[]{(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}),
|
||||
Unpooled.wrappedBuffer(new byte[]{(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00}))
|
||||
wrappedBuffer(new byte[]{(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}),
|
||||
wrappedBuffer(new byte[]{(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00}))
|
||||
> 0);
|
||||
|
||||
assertTrue(ByteBufUtil.compare(
|
||||
Unpooled.wrappedBuffer(new byte[]{(byte) 0xFF}),
|
||||
Unpooled.wrappedBuffer(new byte[]{(byte) 0x00}))
|
||||
wrappedBuffer(new byte[]{(byte) 0xFF}),
|
||||
wrappedBuffer(new byte[]{(byte) 0x00}))
|
||||
> 0);
|
||||
}
|
||||
|
||||
@ -403,7 +403,7 @@ public class ChannelBuffersTest {
|
||||
|
||||
@Test
|
||||
public void testWrapSingleInt() {
|
||||
ByteBuf buffer = Unpooled.copyInt(42);
|
||||
ByteBuf buffer = copyInt(42);
|
||||
assertEquals(4, buffer.capacity());
|
||||
assertEquals(42, buffer.readInt());
|
||||
assertFalse(buffer.readable());
|
||||
@ -411,7 +411,7 @@ public class ChannelBuffersTest {
|
||||
|
||||
@Test
|
||||
public void testWrapInt() {
|
||||
ByteBuf buffer = Unpooled.copyInt(1, 4);
|
||||
ByteBuf buffer = copyInt(1, 4);
|
||||
assertEquals(8, buffer.capacity());
|
||||
assertEquals(1, buffer.readInt());
|
||||
assertEquals(4, buffer.readInt());
|
||||
@ -423,7 +423,7 @@ public class ChannelBuffersTest {
|
||||
|
||||
@Test
|
||||
public void testWrapSingleShort() {
|
||||
ByteBuf buffer = Unpooled.copyShort(42);
|
||||
ByteBuf buffer = copyShort(42);
|
||||
assertEquals(2, buffer.capacity());
|
||||
assertEquals(42, buffer.readShort());
|
||||
assertFalse(buffer.readable());
|
||||
@ -431,7 +431,7 @@ public class ChannelBuffersTest {
|
||||
|
||||
@Test
|
||||
public void testWrapShortFromShortArray() {
|
||||
ByteBuf buffer = Unpooled.copyShort(new short[] { 1, 4 });
|
||||
ByteBuf buffer = copyShort(new short[]{1, 4});
|
||||
assertEquals(4, buffer.capacity());
|
||||
assertEquals(1, buffer.readShort());
|
||||
assertEquals(4, buffer.readShort());
|
||||
@ -443,7 +443,7 @@ public class ChannelBuffersTest {
|
||||
|
||||
@Test
|
||||
public void testWrapShortFromIntArray() {
|
||||
ByteBuf buffer = Unpooled.copyShort(1, 4);
|
||||
ByteBuf buffer = copyShort(1, 4);
|
||||
assertEquals(4, buffer.capacity());
|
||||
assertEquals(1, buffer.readShort());
|
||||
assertEquals(4, buffer.readShort());
|
||||
@ -455,7 +455,7 @@ public class ChannelBuffersTest {
|
||||
|
||||
@Test
|
||||
public void testWrapSingleMedium() {
|
||||
ByteBuf buffer = Unpooled.copyMedium(42);
|
||||
ByteBuf buffer = copyMedium(42);
|
||||
assertEquals(3, buffer.capacity());
|
||||
assertEquals(42, buffer.readMedium());
|
||||
assertFalse(buffer.readable());
|
||||
@ -463,7 +463,7 @@ public class ChannelBuffersTest {
|
||||
|
||||
@Test
|
||||
public void testWrapMedium() {
|
||||
ByteBuf buffer = Unpooled.copyMedium(1, 4);
|
||||
ByteBuf buffer = copyMedium(1, 4);
|
||||
assertEquals(6, buffer.capacity());
|
||||
assertEquals(1, buffer.readMedium());
|
||||
assertEquals(4, buffer.readMedium());
|
||||
@ -475,7 +475,7 @@ public class ChannelBuffersTest {
|
||||
|
||||
@Test
|
||||
public void testWrapSingleLong() {
|
||||
ByteBuf buffer = Unpooled.copyLong(42);
|
||||
ByteBuf buffer = copyLong(42);
|
||||
assertEquals(8, buffer.capacity());
|
||||
assertEquals(42, buffer.readLong());
|
||||
assertFalse(buffer.readable());
|
||||
@ -483,7 +483,7 @@ public class ChannelBuffersTest {
|
||||
|
||||
@Test
|
||||
public void testWrapLong() {
|
||||
ByteBuf buffer = Unpooled.copyLong(1, 4);
|
||||
ByteBuf buffer = copyLong(1, 4);
|
||||
assertEquals(16, buffer.capacity());
|
||||
assertEquals(1, buffer.readLong());
|
||||
assertEquals(4, buffer.readLong());
|
||||
@ -495,7 +495,7 @@ public class ChannelBuffersTest {
|
||||
|
||||
@Test
|
||||
public void testWrapSingleFloat() {
|
||||
ByteBuf buffer = Unpooled.copyFloat(42);
|
||||
ByteBuf buffer = copyFloat(42);
|
||||
assertEquals(4, buffer.capacity());
|
||||
assertEquals(42, buffer.readFloat(), 0.01);
|
||||
assertFalse(buffer.readable());
|
||||
@ -503,7 +503,7 @@ public class ChannelBuffersTest {
|
||||
|
||||
@Test
|
||||
public void testWrapFloat() {
|
||||
ByteBuf buffer = Unpooled.copyFloat(1, 4);
|
||||
ByteBuf buffer = copyFloat(1, 4);
|
||||
assertEquals(8, buffer.capacity());
|
||||
assertEquals(1, buffer.readFloat(), 0.01);
|
||||
assertEquals(4, buffer.readFloat(), 0.01);
|
||||
@ -515,7 +515,7 @@ public class ChannelBuffersTest {
|
||||
|
||||
@Test
|
||||
public void testWrapSingleDouble() {
|
||||
ByteBuf buffer = Unpooled.copyDouble(42);
|
||||
ByteBuf buffer = copyDouble(42);
|
||||
assertEquals(8, buffer.capacity());
|
||||
assertEquals(42, buffer.readDouble(), 0.01);
|
||||
assertFalse(buffer.readable());
|
||||
@ -523,7 +523,7 @@ public class ChannelBuffersTest {
|
||||
|
||||
@Test
|
||||
public void testWrapDouble() {
|
||||
ByteBuf buffer = Unpooled.copyDouble(1, 4);
|
||||
ByteBuf buffer = copyDouble(1, 4);
|
||||
assertEquals(16, buffer.capacity());
|
||||
assertEquals(1, buffer.readDouble(), 0.01);
|
||||
assertEquals(4, buffer.readDouble(), 0.01);
|
||||
@ -535,7 +535,7 @@ public class ChannelBuffersTest {
|
||||
|
||||
@Test
|
||||
public void testWrapBoolean() {
|
||||
ByteBuf buffer = Unpooled.copyBoolean(true, false);
|
||||
ByteBuf buffer = copyBoolean(true, false);
|
||||
assertEquals(2, buffer.capacity());
|
||||
assertEquals(true, buffer.readBoolean());
|
||||
assertEquals(false, buffer.readBoolean());
|
||||
|
@ -40,26 +40,26 @@ public class ReadOnlyChannelBufferTest {
|
||||
|
||||
@Test
|
||||
public void testUnmodifiableBuffer() {
|
||||
assertTrue(Unpooled.unmodifiableBuffer(Unpooled.buffer(1)) instanceof ReadOnlyByteBuf);
|
||||
assertTrue(unmodifiableBuffer(buffer(1)) instanceof ReadOnlyByteBuf);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnwrap() {
|
||||
ByteBuf buf = Unpooled.buffer(1);
|
||||
ByteBuf buf = buffer(1);
|
||||
assertSame(buf, ((WrappedByteBuf) Unpooled.unmodifiableBuffer(buf)).unwrap());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHaveSameByteOrder() {
|
||||
ByteBuf buf = Unpooled.buffer(1);
|
||||
assertSame(Unpooled.BIG_ENDIAN, Unpooled.unmodifiableBuffer(buf).order());
|
||||
ByteBuf buf = buffer(1);
|
||||
assertSame(BIG_ENDIAN, Unpooled.unmodifiableBuffer(buf).order());
|
||||
buf = buf.order(LITTLE_ENDIAN);
|
||||
assertSame(Unpooled.LITTLE_ENDIAN, Unpooled.unmodifiableBuffer(buf).order());
|
||||
assertSame(LITTLE_ENDIAN, Unpooled.unmodifiableBuffer(buf).order());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnReadOnlyDerivedBuffer() {
|
||||
ByteBuf buf = Unpooled.unmodifiableBuffer(Unpooled.buffer(1));
|
||||
ByteBuf buf = unmodifiableBuffer(buffer(1));
|
||||
assertTrue(buf.duplicate() instanceof ReadOnlyByteBuf);
|
||||
assertTrue(buf.slice() instanceof ReadOnlyByteBuf);
|
||||
assertTrue(buf.slice(0, 1) instanceof ReadOnlyByteBuf);
|
||||
@ -68,7 +68,7 @@ public class ReadOnlyChannelBufferTest {
|
||||
|
||||
@Test
|
||||
public void shouldReturnWritableCopy() {
|
||||
ByteBuf buf = Unpooled.unmodifiableBuffer(Unpooled.buffer(1));
|
||||
ByteBuf buf = unmodifiableBuffer(buffer(1));
|
||||
assertFalse(buf.copy() instanceof ReadOnlyByteBuf);
|
||||
}
|
||||
|
||||
|
@ -138,13 +138,13 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
|
||||
// New handshake method with a challenge:
|
||||
res.addHeader(SEC_WEBSOCKET_ORIGIN, req.getHeader(ORIGIN));
|
||||
res.addHeader(SEC_WEBSOCKET_LOCATION, getWebSocketUrl());
|
||||
String subprotocols = req.getHeader(Names.SEC_WEBSOCKET_PROTOCOL);
|
||||
String subprotocols = req.getHeader(SEC_WEBSOCKET_PROTOCOL);
|
||||
if (subprotocols != null) {
|
||||
String selectedSubprotocol = selectSubprotocol(subprotocols);
|
||||
if (selectedSubprotocol == null) {
|
||||
throw new WebSocketHandshakeException("Requested subprotocol(s) not supported: " + subprotocols);
|
||||
} else {
|
||||
res.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, selectedSubprotocol);
|
||||
res.addHeader(SEC_WEBSOCKET_PROTOCOL, selectedSubprotocol);
|
||||
setSelectedSubprotocol(selectedSubprotocol);
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class WebSocketServerProtocolHandler extends ChannelInboundMessageHandler
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, WebSocketFrame frame) throws Exception {
|
||||
if (frame instanceof CloseWebSocketFrame) {
|
||||
WebSocketServerHandshaker handshaker = WebSocketServerProtocolHandler.getHandshaker(ctx);
|
||||
WebSocketServerHandshaker handshaker = getHandshaker(ctx);
|
||||
handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame);
|
||||
return;
|
||||
} else if (frame instanceof PingWebSocketFrame) {
|
||||
|
@ -59,7 +59,7 @@ public class WebSocketServerProtocolHandlerTest {
|
||||
writeUpgradeRequest(ch);
|
||||
assertEquals(SWITCHING_PROTOCOLS, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus());
|
||||
|
||||
ch.writeInbound(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/test"));
|
||||
ch.writeInbound(new DefaultHttpRequest(HTTP_1_1, HttpMethod.GET, "/test"));
|
||||
assertEquals(FORBIDDEN, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus());
|
||||
}
|
||||
|
||||
|
@ -39,14 +39,14 @@ public class DelimiterBasedFrameDecoderTest {
|
||||
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 1, 2 }));
|
||||
try {
|
||||
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0 })));
|
||||
Assert.fail(DecoderException.class.getSimpleName() + " must be raised.");
|
||||
fail(DecoderException.class.getSimpleName() + " must be raised.");
|
||||
} catch (TooLongFrameException e) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 'A', 0 }));
|
||||
ByteBuf buf = (ByteBuf) ch.readInbound();
|
||||
Assert.assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
||||
assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,14 +58,14 @@ public class DelimiterBasedFrameDecoderTest {
|
||||
for (int i = 0; i < 2; i ++) {
|
||||
try {
|
||||
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 1, 2 })));
|
||||
Assert.fail(DecoderException.class.getSimpleName() + " must be raised.");
|
||||
fail(DecoderException.class.getSimpleName() + " must be raised.");
|
||||
} catch (TooLongFrameException e) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 'A', 0 }));
|
||||
ByteBuf buf = (ByteBuf) ch.readInbound();
|
||||
Assert.assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
||||
assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,14 +37,14 @@ public class LengthFieldBasedFrameDecoderTest {
|
||||
assertFalse(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 2 })));
|
||||
try {
|
||||
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0 })));
|
||||
Assert.fail(DecoderException.class.getSimpleName() + " must be raised.");
|
||||
fail(DecoderException.class.getSimpleName() + " must be raised.");
|
||||
} catch (TooLongFrameException e) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 1, 'A' }));
|
||||
ByteBuf buf = (ByteBuf) ch.readInbound();
|
||||
Assert.assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
||||
assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,14 +56,14 @@ public class LengthFieldBasedFrameDecoderTest {
|
||||
for (int i = 0; i < 2; i ++) {
|
||||
try {
|
||||
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 2 })));
|
||||
Assert.fail(DecoderException.class.getSimpleName() + " must be raised.");
|
||||
fail(DecoderException.class.getSimpleName() + " must be raised.");
|
||||
} catch (TooLongFrameException e) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 0, 0, 1, 'A' }));
|
||||
ByteBuf buf = (ByteBuf) ch.readInbound();
|
||||
Assert.assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
||||
assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -256,10 +256,10 @@ final class Deflate {
|
||||
window_size = 2 * w_size;
|
||||
|
||||
// Set the default configuration parameters:
|
||||
max_lazy_match = Deflate.config_table[level].max_lazy;
|
||||
good_match = Deflate.config_table[level].good_length;
|
||||
nice_match = Deflate.config_table[level].nice_length;
|
||||
max_chain_length = Deflate.config_table[level].max_chain;
|
||||
max_lazy_match = config_table[level].max_lazy;
|
||||
good_match = config_table[level].good_length;
|
||||
nice_match = config_table[level].nice_length;
|
||||
max_chain_length = config_table[level].max_chain;
|
||||
|
||||
strstart = 0;
|
||||
block_start = 0;
|
||||
|
@ -142,7 +142,7 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
|
||||
}
|
||||
|
||||
// Cache Validation
|
||||
String ifModifiedSince = request.getHeader(HttpHeaders.Names.IF_MODIFIED_SINCE);
|
||||
String ifModifiedSince = request.getHeader(IF_MODIFIED_SINCE);
|
||||
if (ifModifiedSince != null && !ifModifiedSince.equals("")) {
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
|
||||
Date ifModifiedSinceDate = dateFormatter.parse(ifModifiedSince);
|
||||
@ -232,7 +232,7 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
|
||||
private static final Pattern ALLOWED_FILE_NAME = Pattern.compile("[A-Za-z0-9][-_A-Za-z0-9\\.]*");
|
||||
|
||||
private static void sendListing(ChannelHandlerContext ctx, File dir) {
|
||||
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, HttpResponseStatus.OK);
|
||||
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);
|
||||
response.setHeader(CONTENT_TYPE, "text/html; charset=UTF-8");
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
@ -302,7 +302,7 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
|
||||
* Context
|
||||
*/
|
||||
private static void sendNotModified(ChannelHandlerContext ctx) {
|
||||
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, HttpResponseStatus.NOT_MODIFIED);
|
||||
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, NOT_MODIFIED);
|
||||
setDateHeader(response);
|
||||
|
||||
// Close the connection as soon as the error message is sent.
|
||||
@ -320,7 +320,7 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
|
||||
dateFormatter.setTimeZone(TimeZone.getTimeZone(HTTP_DATE_GMT_TIMEZONE));
|
||||
|
||||
Calendar time = new GregorianCalendar();
|
||||
response.setHeader(HttpHeaders.Names.DATE, dateFormatter.format(time.getTime()));
|
||||
response.setHeader(DATE, dateFormatter.format(time.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -337,14 +337,14 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
|
||||
|
||||
// Date header
|
||||
Calendar time = new GregorianCalendar();
|
||||
response.setHeader(HttpHeaders.Names.DATE, dateFormatter.format(time.getTime()));
|
||||
response.setHeader(DATE, dateFormatter.format(time.getTime()));
|
||||
|
||||
// Add cache headers
|
||||
time.add(Calendar.SECOND, HTTP_CACHE_SECONDS);
|
||||
response.setHeader(HttpHeaders.Names.EXPIRES, dateFormatter.format(time.getTime()));
|
||||
response.setHeader(HttpHeaders.Names.CACHE_CONTROL, "private, max-age=" + HTTP_CACHE_SECONDS);
|
||||
response.setHeader(EXPIRES, dateFormatter.format(time.getTime()));
|
||||
response.setHeader(CACHE_CONTROL, "private, max-age=" + HTTP_CACHE_SECONDS);
|
||||
response.setHeader(
|
||||
HttpHeaders.Names.LAST_MODIFIED, dateFormatter.format(new Date(fileToCache.lastModified())));
|
||||
LAST_MODIFIED, dateFormatter.format(new Date(fileToCache.lastModified())));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -357,7 +357,7 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
|
||||
*/
|
||||
private static void setContentTypeHeader(HttpResponse response, File file) {
|
||||
MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
|
||||
response.setHeader(HttpHeaders.Names.CONTENT_TYPE, mimeTypesMap.getContentType(file.getPath()));
|
||||
response.setHeader(CONTENT_TYPE, mimeTypesMap.getContentType(file.getPath()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
|
||||
|
||||
// new method
|
||||
Set<Cookie> cookies;
|
||||
String value = request.getHeader(HttpHeaders.Names.COOKIE);
|
||||
String value = request.getHeader(COOKIE);
|
||||
if (value == null) {
|
||||
cookies = Collections.emptySet();
|
||||
} else {
|
||||
@ -302,23 +302,23 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
|
||||
responseContent.setLength(0);
|
||||
|
||||
// Decide whether to close the connection or not.
|
||||
boolean close = HttpHeaders.Values.CLOSE.equalsIgnoreCase(request.getHeader(HttpHeaders.Names.CONNECTION))
|
||||
boolean close = HttpHeaders.Values.CLOSE.equalsIgnoreCase(request.getHeader(CONNECTION))
|
||||
|| request.getProtocolVersion().equals(HttpVersion.HTTP_1_0)
|
||||
&& !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request.getHeader(HttpHeaders.Names.CONNECTION));
|
||||
&& !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request.getHeader(CONNECTION));
|
||||
|
||||
// Build the response object.
|
||||
HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
|
||||
response.setContent(buf);
|
||||
response.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/plain; charset=UTF-8");
|
||||
response.setHeader(CONTENT_TYPE, "text/plain; charset=UTF-8");
|
||||
|
||||
if (!close) {
|
||||
// There's no need to add 'Content-Length' header
|
||||
// if this is the last response.
|
||||
response.setHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(buf.readableBytes()));
|
||||
response.setHeader(CONTENT_LENGTH, String.valueOf(buf.readableBytes()));
|
||||
}
|
||||
|
||||
Set<Cookie> cookies;
|
||||
String value = request.getHeader(HttpHeaders.Names.COOKIE);
|
||||
String value = request.getHeader(COOKIE);
|
||||
if (value == null) {
|
||||
cookies = Collections.emptySet();
|
||||
} else {
|
||||
@ -414,8 +414,8 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
|
||||
// Build the response object.
|
||||
HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
|
||||
response.setContent(buf);
|
||||
response.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/html; charset=UTF-8");
|
||||
response.setHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(buf.readableBytes()));
|
||||
response.setHeader(CONTENT_TYPE, "text/html; charset=UTF-8");
|
||||
response.setHeader(CONTENT_LENGTH, String.valueOf(buf.readableBytes()));
|
||||
// Write the response.
|
||||
ctx.channel().write(response);
|
||||
}
|
||||
|
@ -145,6 +145,6 @@ public class WebSocketServerHandler extends ChannelInboundMessageHandlerAdapter<
|
||||
}
|
||||
|
||||
private static String getWebSocketLocation(HttpRequest req) {
|
||||
return "ws://" + req.getHeader(HttpHeaders.Names.HOST) + WEBSOCKET_PATH;
|
||||
return "ws://" + req.getHeader(HOST) + WEBSOCKET_PATH;
|
||||
}
|
||||
}
|
||||
|
@ -146,6 +146,6 @@ public class WebSocketSslServerHandler extends ChannelInboundMessageHandlerAdapt
|
||||
}
|
||||
|
||||
private static String getWebSocketLocation(HttpRequest req) {
|
||||
return "wss://" + req.getHeader(HttpHeaders.Names.HOST) + WEBSOCKET_PATH;
|
||||
return "wss://" + req.getHeader(HOST) + WEBSOCKET_PATH;
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class LocalTimeServerHandler extends ChannelInboundMessageHandlerAdapter<
|
||||
for (Location l: locations.getLocationList()) {
|
||||
TimeZone tz = TimeZone.getTimeZone(
|
||||
toString(l.getContinent()) + '/' + l.getCity());
|
||||
Calendar calendar = Calendar.getInstance(tz);
|
||||
Calendar calendar = getInstance(tz);
|
||||
calendar.setTimeInMillis(currentTime);
|
||||
|
||||
builder.addLocalTime(LocalTime.newBuilder().
|
||||
|
@ -110,7 +110,7 @@ public class DatagramMulticastTest extends AbstractDatagramTest {
|
||||
fail = true;
|
||||
}
|
||||
|
||||
Assert.assertEquals(1, msg.data().readInt());
|
||||
assertEquals(1, msg.data().readInt());
|
||||
latch.countDown();
|
||||
|
||||
// mark the handler as done as we only are supposed to receive one message
|
||||
@ -121,7 +121,7 @@ public class DatagramMulticastTest extends AbstractDatagramTest {
|
||||
boolean success = latch.await(10, TimeUnit.SECONDS);
|
||||
if (fail) {
|
||||
// fail if we receive an message after we are done
|
||||
Assert.fail();
|
||||
fail();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class DatagramUnicastTest extends AbstractDatagramTest {
|
||||
public void messageReceived(
|
||||
ChannelHandlerContext ctx,
|
||||
DatagramPacket msg) throws Exception {
|
||||
Assert.assertEquals(1, msg.data().readInt());
|
||||
assertEquals(1, msg.data().readInt());
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
|
@ -38,7 +38,7 @@ import static com.sun.nio.sctp.SctpStandardSocketOptions.InitMaxStreams;
|
||||
* <td>{@code "sendBufferSize"}</td><td>{@link #setSendBufferSize(int)}</td>
|
||||
* </tr><tr>
|
||||
* <td>{@code "sctpInitMaxStreams"}</td>
|
||||
* <td>{@link #setInitMaxStreams(com.sun.nio.sctp.SctpStandardSocketOptions.InitMaxStreams)}</td>
|
||||
* <td>{@link #setInitMaxStreams(InitMaxStreams)}</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
@ -39,7 +39,7 @@ import static com.sun.nio.sctp.SctpStandardSocketOptions.InitMaxStreams;
|
||||
* <td>{@code "sendBufferSize"}</td><td>{@link #setSendBufferSize(int)}</td>
|
||||
* </tr><tr>
|
||||
* <td>{@code "sctpInitMaxStreams"}</td>
|
||||
* <td>{@link #setInitMaxStreams(com.sun.nio.sctp.SctpStandardSocketOptions.InitMaxStreams)} (int)}}</td>
|
||||
* <td>{@link #setInitMaxStreams(InitMaxStreams)} (int)}}</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user