From 4a13f66e131c3eb3d4293c198be0a613644d3a9c Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Tue, 24 Jun 2014 17:39:46 +0900 Subject: [PATCH] Remove 'get' prefix from all HTTP/SPDY messages Motivation: Persuit for the consistency in method naming Modifications: - Remove the 'get' prefix from all HTTP/SPDY message classes - Fix some inspector warnings Result: Consistency Fixes #2594 --- .../io/netty/buffer/SlicedByteBufTest.java | 6 +- .../codec/http/ClientCookieEncoder.java | 18 +- .../codec/http/ComposedLastHttpContent.java | 8 +- .../io/netty/handler/codec/http/Cookie.java | 72 ++++- .../handler/codec/http/DefaultCookie.java | 112 +++++-- .../codec/http/DefaultFullHttpRequest.java | 4 +- .../codec/http/DefaultFullHttpResponse.java | 4 +- .../codec/http/DefaultHttpContent.java | 2 +- .../codec/http/DefaultHttpMessage.java | 8 +- .../handler/codec/http/DefaultHttpObject.java | 6 + .../codec/http/DefaultHttpRequest.java | 20 +- .../codec/http/DefaultHttpResponse.java | 12 +- .../handler/codec/http/HttpClientCodec.java | 4 +- .../codec/http/HttpContentDecoder.java | 6 +- .../codec/http/HttpContentEncoder.java | 4 +- .../netty/handler/codec/http/HttpHeaders.java | 10 +- .../netty/handler/codec/http/HttpMessage.java | 10 +- .../netty/handler/codec/http/HttpObject.java | 9 +- .../codec/http/HttpObjectAggregator.java | 16 +- .../handler/codec/http/HttpObjectDecoder.java | 4 +- .../netty/handler/codec/http/HttpRequest.java | 16 +- .../codec/http/HttpRequestEncoder.java | 6 +- .../handler/codec/http/HttpResponse.java | 8 +- .../codec/http/HttpResponseEncoder.java | 4 +- .../handler/codec/http/LastHttpContent.java | 6 + .../codec/http/QueryStringDecoder.java | 4 +- .../codec/http/QueryStringEncoder.java | 2 +- .../codec/http/ServerCookieEncoder.java | 40 +-- .../handler/codec/http/cors/CorsHandler.java | 6 +- .../multipart/CaseIgnoringComparator.java | 1 - .../multipart/HttpPostRequestEncoder.java | 31 +- .../websocketx/WebSocket08FrameDecoder.java | 2 +- .../WebSocketClientHandshaker00.java | 4 +- .../WebSocketClientHandshaker07.java | 4 +- .../WebSocketClientHandshaker08.java | 4 +- .../WebSocketClientHandshaker13.java | 4 +- .../WebSocketClientHandshakerFactory.java | 2 +- ...bSocketClientProtocolHandshakeHandler.java | 2 +- .../WebSocketServerProtocolHandler.java | 2 +- ...bSocketServerProtocolHandshakeHandler.java | 6 +- .../codec/rtsp/RtspRequestEncoder.java | 6 +- .../codec/rtsp/RtspResponseEncoder.java | 6 +- .../codec/spdy/DefaultSpdyDataFrame.java | 6 +- .../codec/spdy/DefaultSpdyGoAwayFrame.java | 16 +- .../codec/spdy/DefaultSpdyHeadersFrame.java | 2 +- .../codec/spdy/DefaultSpdyPingFrame.java | 8 +- .../codec/spdy/DefaultSpdyRstStreamFrame.java | 10 +- .../codec/spdy/DefaultSpdySettingsFrame.java | 8 +- .../codec/spdy/DefaultSpdyStreamFrame.java | 6 + .../codec/spdy/DefaultSpdySynReplyFrame.java | 2 +- .../codec/spdy/DefaultSpdySynStreamFrame.java | 47 ++- .../spdy/DefaultSpdyWindowUpdateFrame.java | 16 +- .../handler/codec/spdy/SpdyFrameCodec.java | 26 +- .../handler/codec/spdy/SpdyFrameEncoder.java | 2 +- .../handler/codec/spdy/SpdyGoAwayFrame.java | 16 +- .../codec/spdy/SpdyHeaderBlockRawDecoder.java | 2 +- .../spdy/SpdyHeaderBlockZlibDecoder.java | 4 +- .../handler/codec/spdy/SpdyHttpDecoder.java | 14 +- .../handler/codec/spdy/SpdyHttpEncoder.java | 16 +- .../spdy/SpdyHttpResponseStreamIdHandler.java | 2 +- .../handler/codec/spdy/SpdyPingFrame.java | 8 +- .../codec/spdy/SpdyRstStreamFrame.java | 8 +- .../netty/handler/codec/spdy/SpdySession.java | 2 +- .../codec/spdy/SpdySessionHandler.java | 40 +-- .../handler/codec/spdy/SpdySessionStatus.java | 28 +- .../handler/codec/spdy/SpdySettingsFrame.java | 8 +- .../handler/codec/spdy/SpdyStreamFrame.java | 8 +- .../handler/codec/spdy/SpdyStreamStatus.java | 28 +- .../codec/spdy/SpdySynStreamFrame.java | 24 +- .../netty/handler/codec/spdy/SpdyVersion.java | 2 +- .../codec/spdy/SpdyWindowUpdateFrame.java | 16 +- .../handler/codec/http/CookieDecoderTest.java | 296 +++++++++--------- .../codec/http/HttpChunkedInputTest.java | 7 +- .../codec/http/HttpInvalidMessageTest.java | 16 +- .../codec/http/HttpResponseDecoderTest.java | 66 ++-- .../codec/http/cors/CorsHandlerTest.java | 8 +- .../WebSocketServerProtocolHandlerTest.java | 10 +- .../codec/spdy/SpdyFrameDecoderTest.java | 2 +- .../codec/spdy/SpdySessionHandlerTest.java | 24 +- .../file/HttpStaticFileServerHandler.java | 4 +- .../http/snoop/HttpSnoopClientHandler.java | 4 +- .../http/snoop/HttpSnoopServerHandler.java | 6 +- .../http/upload/HttpUploadClientHandler.java | 6 +- .../http/upload/HttpUploadServerHandler.java | 20 +- .../client/WebSocketClientHandler.java | 2 +- .../server/WebSocketServerHandler.java | 12 +- .../client/HttpResponseClientHandler.java | 4 +- .../transport/socket/SocketAutoReadTest.java | 6 +- .../autobahn/AutobahnServerHandler.java | 10 +- 89 files changed, 870 insertions(+), 509 deletions(-) diff --git a/buffer/src/test/java/io/netty/buffer/SlicedByteBufTest.java b/buffer/src/test/java/io/netty/buffer/SlicedByteBufTest.java index 32e0be795a..ab5fa344fb 100644 --- a/buffer/src/test/java/io/netty/buffer/SlicedByteBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/SlicedByteBufTest.java @@ -15,13 +15,11 @@ */ package io.netty.buffer; -import static io.netty.buffer.Unpooled.LITTLE_ENDIAN; -import static io.netty.util.ReferenceCountUtil.releaseLater; -import static org.junit.Assert.*; +import org.junit.Test; import java.util.Random; -import org.junit.Test; +import static org.junit.Assert.*; /** * Tests sliced channel buffers diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/ClientCookieEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/ClientCookieEncoder.java index 5a5b5bae74..308e890f1a 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/ClientCookieEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/ClientCookieEncoder.java @@ -80,27 +80,27 @@ public final class ClientCookieEncoder { } private static void encode(StringBuilder buf, Cookie c) { - if (c.getVersion() >= 1) { + if (c.version() >= 1) { add(buf, '$' + CookieHeaderNames.VERSION, 1); } - add(buf, c.getName(), c.getValue()); + add(buf, c.name(), c.value()); - if (c.getPath() != null) { - add(buf, '$' + CookieHeaderNames.PATH, c.getPath()); + if (c.path() != null) { + add(buf, '$' + CookieHeaderNames.PATH, c.path()); } - if (c.getDomain() != null) { - add(buf, '$' + CookieHeaderNames.DOMAIN, c.getDomain()); + if (c.domain() != null) { + add(buf, '$' + CookieHeaderNames.DOMAIN, c.domain()); } - if (c.getVersion() >= 1) { - if (!c.getPorts().isEmpty()) { + if (c.version() >= 1) { + if (!c.ports().isEmpty()) { buf.append('$'); buf.append(CookieHeaderNames.PORT); buf.append((char) HttpConstants.EQUALS); buf.append((char) HttpConstants.DOUBLE_QUOTE); - for (int port: c.getPorts()) { + for (int port: c.ports()) { buf.append(port); buf.append((char) HttpConstants.COMMA); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/ComposedLastHttpContent.java b/codec-http/src/main/java/io/netty/handler/codec/http/ComposedLastHttpContent.java index be9278bd47..9195b28273 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/ComposedLastHttpContent.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/ComposedLastHttpContent.java @@ -60,10 +60,16 @@ final class ComposedLastHttpContent implements LastHttpContent { } @Override - public DecoderResult getDecoderResult() { + public DecoderResult decoderResult() { return result; } + @Override + @Deprecated + public DecoderResult getDecoderResult() { + return decoderResult(); + } + @Override public void setDecoderResult(DecoderResult result) { this.result = result; diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/Cookie.java b/codec-http/src/main/java/io/netty/handler/codec/http/Cookie.java index c154d2de26..45e47d6791 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/Cookie.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/Cookie.java @@ -23,19 +23,31 @@ import java.util.Set; */ public interface Cookie extends Comparable { + /** + * @deprecated Use {@link #name()} instead. + */ + @Deprecated + String getName(); + /** * Returns the name of this {@link Cookie}. * * @return The name of this {@link Cookie} */ - String getName(); + String name(); + + /** + * @deprecated Use {@link #value()} instead. + */ + @Deprecated + String getValue(); /** * Returns the value of this {@link Cookie}. * * @return The value of this {@link Cookie} */ - String getValue(); + String value(); /** * Sets the value of this {@link Cookie}. @@ -44,12 +56,18 @@ public interface Cookie extends Comparable { */ void setValue(String value); + /** + * @deprecated Use {@link #domain()} instead. + */ + @Deprecated + String getDomain(); + /** * Returns the domain of this {@link Cookie}. * * @return The domain of this {@link Cookie} */ - String getDomain(); + String domain(); /** * Sets the domain of this {@link Cookie}. @@ -58,12 +76,18 @@ public interface Cookie extends Comparable { */ void setDomain(String domain); + /** + * @deprecated Use {@link #path()} instead. + */ + @Deprecated + String getPath(); + /** * Returns the path of this {@link Cookie}. * * @return The {@link Cookie}'s path */ - String getPath(); + String path(); /** * Sets the path of this {@link Cookie}. @@ -72,12 +96,18 @@ public interface Cookie extends Comparable { */ void setPath(String path); + /** + * @deprecated Use {@link #comment()} instead. + */ + @Deprecated + String getComment(); + /** * Returns the comment of this {@link Cookie}. * * @return The comment of this {@link Cookie} */ - String getComment(); + String comment(); /** * Sets the comment of this {@link Cookie}. @@ -86,12 +116,18 @@ public interface Cookie extends Comparable { */ void setComment(String comment); + /** + * @deprecated Use {@link #maxAge()} instead. + */ + @Deprecated + long getMaxAge(); + /** * Returns the maximum age of this {@link Cookie} in seconds or {@link Long#MIN_VALUE} if unspecified * * @return The maximum age of this {@link Cookie} */ - long getMaxAge(); + long maxAge(); /** * Sets the maximum age of this {@link Cookie} in seconds. @@ -104,12 +140,18 @@ public interface Cookie extends Comparable { */ void setMaxAge(long maxAge); + /** + * @deprecated Use {@link #version()} instead. + */ + @Deprecated + int getVersion(); + /** * Returns the version of this {@link Cookie}. * * @return The version of this {@link Cookie} */ - int getVersion(); + int version(); /** * Sets the version of this {@link Cookie}. @@ -153,12 +195,18 @@ public interface Cookie extends Comparable { */ void setHttpOnly(boolean httpOnly); + /** + * @deprecated Use {@link #commentUrl()} instead. + */ + @Deprecated + String getCommentUrl(); + /** * Returns the comment URL of this {@link Cookie}. * * @return The comment URL of this {@link Cookie} */ - String getCommentUrl(); + String commentUrl(); /** * Sets the comment URL of this {@link Cookie}. @@ -184,12 +232,18 @@ public interface Cookie extends Comparable { */ void setDiscard(boolean discard); + /** + * @deprecated Use {@link #ports()} instead. + */ + @Deprecated + Set getPorts(); + /** * Returns the ports that this {@link Cookie} can be accessed on. * * @return The {@link Set} of ports that this {@link Cookie} can use */ - Set getPorts(); + Set ports(); /** * Sets the ports that this {@link Cookie} can be accessed on. diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java index 7e6512196c..66b421c607 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java @@ -78,12 +78,24 @@ public class DefaultCookie implements Cookie { } @Override + @Deprecated public String getName() { + return name(); + } + + @Override + public String name() { return name; } @Override + @Deprecated public String getValue() { + return value(); + } + + @Override + public String value() { return value; } @@ -96,7 +108,13 @@ public class DefaultCookie implements Cookie { } @Override + @Deprecated public String getDomain() { + return domain(); + } + + @Override + public String domain() { return domain; } @@ -106,7 +124,13 @@ public class DefaultCookie implements Cookie { } @Override + @Deprecated public String getPath() { + return path(); + } + + @Override + public String path() { return path; } @@ -116,7 +140,13 @@ public class DefaultCookie implements Cookie { } @Override + @Deprecated public String getComment() { + return comment(); + } + + @Override + public String comment() { return comment; } @@ -126,7 +156,13 @@ public class DefaultCookie implements Cookie { } @Override + @Deprecated public String getCommentUrl() { + return commentUrl(); + } + + @Override + public String commentUrl() { return commentUrl; } @@ -146,7 +182,13 @@ public class DefaultCookie implements Cookie { } @Override + @Deprecated public Set getPorts() { + return ports(); + } + + @Override + public Set ports() { if (unmodifiablePorts == null) { unmodifiablePorts = Collections.unmodifiableSet(ports); } @@ -193,7 +235,13 @@ public class DefaultCookie implements Cookie { } @Override + @Deprecated public long getMaxAge() { + return maxAge(); + } + + @Override + public long maxAge() { return maxAge; } @@ -203,7 +251,13 @@ public class DefaultCookie implements Cookie { } @Override + @Deprecated public int getVersion() { + return version(); + } + + @Override + public int version() { return version; } @@ -234,7 +288,7 @@ public class DefaultCookie implements Cookie { @Override public int hashCode() { - return getName().hashCode(); + return name().hashCode(); } @Override @@ -244,28 +298,28 @@ public class DefaultCookie implements Cookie { } Cookie that = (Cookie) o; - if (!getName().equalsIgnoreCase(that.getName())) { + if (!name().equalsIgnoreCase(that.name())) { return false; } - if (getPath() == null) { - if (that.getPath() != null) { + if (path() == null) { + if (that.path() != null) { return false; } - } else if (that.getPath() == null) { + } else if (that.path() == null) { return false; - } else if (!getPath().equals(that.getPath())) { + } else if (!path().equals(that.path())) { return false; } - if (getDomain() == null) { - if (that.getDomain() != null) { + if (domain() == null) { + if (that.domain() != null) { return false; } - } else if (that.getDomain() == null) { + } else if (that.domain() == null) { return false; } else { - return getDomain().equalsIgnoreCase(that.getDomain()); + return domain().equalsIgnoreCase(that.domain()); } return true; @@ -274,32 +328,32 @@ public class DefaultCookie implements Cookie { @Override public int compareTo(Cookie c) { int v; - v = getName().compareToIgnoreCase(c.getName()); + v = name().compareToIgnoreCase(c.name()); if (v != 0) { return v; } - if (getPath() == null) { - if (c.getPath() != null) { + if (path() == null) { + if (c.path() != null) { return -1; } - } else if (c.getPath() == null) { + } else if (c.path() == null) { return 1; } else { - v = getPath().compareTo(c.getPath()); + v = path().compareTo(c.path()); if (v != 0) { return v; } } - if (getDomain() == null) { - if (c.getDomain() != null) { + if (domain() == null) { + if (c.domain() != null) { return -1; } - } else if (c.getDomain() == null) { + } else if (c.domain() == null) { return 1; } else { - v = getDomain().compareToIgnoreCase(c.getDomain()); + v = domain().compareToIgnoreCase(c.domain()); return v; } @@ -309,24 +363,24 @@ public class DefaultCookie implements Cookie { @Override public String toString() { StringBuilder buf = new StringBuilder(); - buf.append(getName()); + buf.append(name()); buf.append('='); - buf.append(getValue()); - if (getDomain() != null) { + buf.append(value()); + if (domain() != null) { buf.append(", domain="); - buf.append(getDomain()); + buf.append(domain()); } - if (getPath() != null) { + if (path() != null) { buf.append(", path="); - buf.append(getPath()); + buf.append(path()); } - if (getComment() != null) { + if (comment() != null) { buf.append(", comment="); - buf.append(getComment()); + buf.append(comment()); } - if (getMaxAge() >= 0) { + if (maxAge() >= 0) { buf.append(", maxAge="); - buf.append(getMaxAge()); + buf.append(maxAge()); buf.append('s'); } if (isSecure()) { diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultFullHttpRequest.java b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultFullHttpRequest.java index 8ea1983ef3..d9f6430ee9 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultFullHttpRequest.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultFullHttpRequest.java @@ -103,7 +103,7 @@ public class DefaultFullHttpRequest extends DefaultHttpRequest implements FullHt @Override public FullHttpRequest copy() { DefaultFullHttpRequest copy = new DefaultFullHttpRequest( - getProtocolVersion(), getMethod(), getUri(), content().copy(), validateHeaders); + protocolVersion(), method(), uri(), content().copy(), validateHeaders); copy.headers().set(headers()); copy.trailingHeaders().set(trailingHeaders()); return copy; @@ -112,7 +112,7 @@ public class DefaultFullHttpRequest extends DefaultHttpRequest implements FullHt @Override public FullHttpRequest duplicate() { DefaultFullHttpRequest duplicate = new DefaultFullHttpRequest( - getProtocolVersion(), getMethod(), getUri(), content().duplicate(), validateHeaders); + protocolVersion(), method(), uri(), content().duplicate(), validateHeaders); duplicate.headers().set(headers()); duplicate.trailingHeaders().set(trailingHeaders()); return duplicate; diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultFullHttpResponse.java b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultFullHttpResponse.java index 77d19e594c..d5982b1de8 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultFullHttpResponse.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultFullHttpResponse.java @@ -99,7 +99,7 @@ public class DefaultFullHttpResponse extends DefaultHttpResponse implements Full @Override public FullHttpResponse copy() { DefaultFullHttpResponse copy = new DefaultFullHttpResponse( - getProtocolVersion(), getStatus(), content().copy(), validateHeaders); + protocolVersion(), status(), content().copy(), validateHeaders); copy.headers().set(headers()); copy.trailingHeaders().set(trailingHeaders()); return copy; @@ -107,7 +107,7 @@ public class DefaultFullHttpResponse extends DefaultHttpResponse implements Full @Override public FullHttpResponse duplicate() { - DefaultFullHttpResponse duplicate = new DefaultFullHttpResponse(getProtocolVersion(), getStatus(), + DefaultFullHttpResponse duplicate = new DefaultFullHttpResponse(protocolVersion(), status(), content().duplicate(), validateHeaders); duplicate.headers().set(headers()); duplicate.trailingHeaders().set(trailingHeaders()); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpContent.java b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpContent.java index b88a0ff8a3..5a599015ab 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpContent.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpContent.java @@ -80,6 +80,6 @@ public class DefaultHttpContent extends DefaultHttpObject implements HttpContent @Override public String toString() { return StringUtil.simpleClassName(this) + - "(data: " + content() + ", getDecoderResult: " + getDecoderResult() + ')'; + "(data: " + content() + ", decoderResult: " + decoderResult() + ')'; } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpMessage.java b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpMessage.java index b6e0889414..be1483fd3b 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpMessage.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpMessage.java @@ -48,7 +48,13 @@ public abstract class DefaultHttpMessage extends DefaultHttpObject implements Ht } @Override + @Deprecated public HttpVersion getProtocolVersion() { + return protocolVersion(); + } + + @Override + public HttpVersion protocolVersion() { return version; } @@ -57,7 +63,7 @@ public abstract class DefaultHttpMessage extends DefaultHttpObject implements Ht StringBuilder buf = new StringBuilder(); buf.append(StringUtil.simpleClassName(this)); buf.append("(version: "); - buf.append(getProtocolVersion().text()); + buf.append(protocolVersion().text()); buf.append(", keepAlive: "); buf.append(HttpHeaders.isKeepAlive(this)); buf.append(')'); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpObject.java b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpObject.java index 11f3c23c55..d08ad72b94 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpObject.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpObject.java @@ -26,6 +26,12 @@ public class DefaultHttpObject implements HttpObject { } @Override + public DecoderResult decoderResult() { + return decoderResult; + } + + @Override + @Deprecated public DecoderResult getDecoderResult() { return decoderResult; } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpRequest.java b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpRequest.java index 21e9fff377..0eabb97c3b 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpRequest.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpRequest.java @@ -57,12 +57,24 @@ public class DefaultHttpRequest extends DefaultHttpMessage implements HttpReques } @Override + @Deprecated public HttpMethod getMethod() { + return method(); + } + + @Override + public HttpMethod method() { return method; } @Override + @Deprecated public String getUri() { + return uri(); + } + + @Override + public String uri() { return uri; } @@ -95,14 +107,14 @@ public class DefaultHttpRequest extends DefaultHttpMessage implements HttpReques StringBuilder buf = new StringBuilder(); buf.append(StringUtil.simpleClassName(this)); buf.append("(decodeResult: "); - buf.append(getDecoderResult()); + buf.append(decoderResult()); buf.append(')'); buf.append(StringUtil.NEWLINE); - buf.append(getMethod().toString()); + buf.append(method()); buf.append(' '); - buf.append(getUri()); + buf.append(uri()); buf.append(' '); - buf.append(getProtocolVersion().text()); + buf.append(protocolVersion().text()); buf.append(StringUtil.NEWLINE); appendHeaders(buf); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpResponse.java b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpResponse.java index 057839c0dd..40f3469a2d 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpResponse.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpResponse.java @@ -50,7 +50,13 @@ public class DefaultHttpResponse extends DefaultHttpMessage implements HttpRespo } @Override + @Deprecated public HttpResponseStatus getStatus() { + return status(); + } + + @Override + public HttpResponseStatus status() { return status; } @@ -74,12 +80,12 @@ public class DefaultHttpResponse extends DefaultHttpMessage implements HttpRespo StringBuilder buf = new StringBuilder(); buf.append(StringUtil.simpleClassName(this)); buf.append("(decodeResult: "); - buf.append(getDecoderResult()); + buf.append(decoderResult()); buf.append(')'); buf.append(StringUtil.NEWLINE); - buf.append(getProtocolVersion().text()); + buf.append(protocolVersion().text()); buf.append(' '); - buf.append(getStatus().toString()); + buf.append(status()); buf.append(StringUtil.NEWLINE); appendHeaders(buf); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java index e7a7610a9d..4c40836bca 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java @@ -100,7 +100,7 @@ public final class HttpClientCodec protected void encode( ChannelHandlerContext ctx, Object msg, List out) throws Exception { if (msg instanceof HttpRequest && !done) { - queue.offer(((HttpRequest) msg).getMethod()); + queue.offer(((HttpRequest) msg).method()); } super.encode(ctx, msg, out); @@ -156,7 +156,7 @@ public final class HttpClientCodec @Override protected boolean isContentAlwaysEmpty(HttpMessage msg) { - final int statusCode = ((HttpResponse) msg).getStatus().code(); + final int statusCode = ((HttpResponse) msg).status().code(); if (statusCode == 100) { // 100-continue response should be excluded from paired comparison. return true; diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecoder.java index 789e829b00..d2f22fc118 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentDecoder.java @@ -51,7 +51,7 @@ public abstract class HttpContentDecoder extends MessageToMessageDecoder out) throws Exception { - if (msg instanceof HttpResponse && ((HttpResponse) msg).getStatus().code() == 100) { + if (msg instanceof HttpResponse && ((HttpResponse) msg).status().code() == 100) { if (!(msg instanceof LastHttpContent)) { continueResponse = true; @@ -184,8 +184,8 @@ public abstract class HttpContentDecoder extends MessageToMessageDecoder> return false; } - if (message.getProtocolVersion().isKeepAliveDefault()) { + if (message.protocolVersion().isKeepAliveDefault()) { return !equalsIgnoreCase(CLOSE_ENTITY, connection); } else { return equalsIgnoreCase(KEEP_ALIVE_ENTITY, connection); @@ -598,7 +598,7 @@ public abstract class HttpHeaders implements Iterable> */ public static void setKeepAlive(HttpMessage message, boolean keepAlive) { HttpHeaders h = message.headers(); - if (message.getProtocolVersion().isKeepAliveDefault()) { + if (message.protocolVersion().isKeepAliveDefault()) { if (keepAlive) { h.remove(CONNECTION_ENTITY); } else { @@ -1010,14 +1010,14 @@ public abstract class HttpHeaders implements Iterable> HttpHeaders h = message.headers(); if (message instanceof HttpRequest) { HttpRequest req = (HttpRequest) message; - if (HttpMethod.GET.equals(req.getMethod()) && + if (HttpMethod.GET.equals(req.method()) && h.contains(SEC_WEBSOCKET_KEY1_ENTITY) && h.contains(SEC_WEBSOCKET_KEY2_ENTITY)) { return 8; } } else if (message instanceof HttpResponse) { HttpResponse res = (HttpResponse) message; - if (res.getStatus().code() == 101 && + if (res.status().code() == 101 && h.contains(SEC_WEBSOCKET_ORIGIN_ENTITY) && h.contains(SEC_WEBSOCKET_LOCATION_ENTITY)) { return 16; @@ -1105,7 +1105,7 @@ public abstract class HttpHeaders implements Iterable> } // It works only on HTTP/1.1 or later. - if (message.getProtocolVersion().compareTo(HttpVersion.HTTP_1_1) < 0) { + if (message.protocolVersion().compareTo(HttpVersion.HTTP_1_1) < 0) { return false; } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpMessage.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpMessage.java index 7faabd2f60..357ad99bca 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpMessage.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpMessage.java @@ -27,12 +27,16 @@ package io.netty.handler.codec.http; public interface HttpMessage extends HttpObject { /** - * Returns the protocol version of this {@link HttpMessage} - * - * @return The protocol version + * @deprecated Use {@link #protocolVersion()} instead. */ + @Deprecated HttpVersion getProtocolVersion(); + /** + * Returns the protocol version of this {@link HttpMessage} + */ + HttpVersion protocolVersion(); + /** * Set the protocol version of this {@link HttpMessage} */ diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObject.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObject.java index f28a785cb8..2bdc379a5f 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObject.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObject.java @@ -18,10 +18,17 @@ package io.netty.handler.codec.http; import io.netty.handler.codec.DecoderResult; public interface HttpObject { + + /** + * @deprecated Use {@link #getDecoderResult()} instead. + */ + @Deprecated + DecoderResult getDecoderResult(); + /** * Returns the result of decoding this message. */ - DecoderResult getDecoderResult(); + DecoderResult decoderResult(); /** * Updates the result of decoding this message. This method is supposed to be invoked by {@link HttpObjectDecoder}. diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectAggregator.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectAggregator.java index 43d87dabc0..d2d1384227 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectAggregator.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectAggregator.java @@ -136,7 +136,7 @@ public class HttpObjectAggregator extends MessageToMessageDecoder { }); } - if (!m.getDecoderResult().isSuccess()) { + if (!m.decoderResult().isSuccess()) { removeTransferEncodingChunked(m); out.add(toFullMessage(m)); this.currentMessage = null; @@ -144,12 +144,12 @@ public class HttpObjectAggregator extends MessageToMessageDecoder { } if (msg instanceof HttpRequest) { HttpRequest header = (HttpRequest) msg; - this.currentMessage = currentMessage = new DefaultFullHttpRequest(header.getProtocolVersion(), - header.getMethod(), header.getUri(), Unpooled.compositeBuffer(maxCumulationBufferComponents)); + this.currentMessage = currentMessage = new DefaultFullHttpRequest(header.protocolVersion(), + header.method(), header.uri(), Unpooled.compositeBuffer(maxCumulationBufferComponents)); } else if (msg instanceof HttpResponse) { HttpResponse header = (HttpResponse) msg; this.currentMessage = currentMessage = new DefaultFullHttpResponse( - header.getProtocolVersion(), header.getStatus(), + header.protocolVersion(), header.status(), Unpooled.compositeBuffer(maxCumulationBufferComponents)); } else { throw new Error(); @@ -193,9 +193,9 @@ public class HttpObjectAggregator extends MessageToMessageDecoder { } final boolean last; - if (!chunk.getDecoderResult().isSuccess()) { + if (!chunk.decoderResult().isSuccess()) { currentMessage.setDecoderResult( - DecoderResult.failure(chunk.getDecoderResult().cause())); + DecoderResult.failure(chunk.decoderResult().cause())); last = true; } else { last = chunk instanceof LastHttpContent; @@ -259,11 +259,11 @@ public class HttpObjectAggregator extends MessageToMessageDecoder { if (msg instanceof HttpRequest) { HttpRequest req = (HttpRequest) msg; fullMsg = new DefaultFullHttpRequest( - req.getProtocolVersion(), req.getMethod(), req.getUri(), Unpooled.EMPTY_BUFFER, false); + req.protocolVersion(), req.method(), req.uri(), Unpooled.EMPTY_BUFFER, false); } else if (msg instanceof HttpResponse) { HttpResponse res = (HttpResponse) msg; fullMsg = new DefaultFullHttpResponse( - res.getProtocolVersion(), res.getStatus(), Unpooled.EMPTY_BUFFER, false); + res.protocolVersion(), res.status(), Unpooled.EMPTY_BUFFER, false); } else { throw new IllegalStateException(); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java index 05b915fbbd..ada45bdc41 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java @@ -404,7 +404,7 @@ public abstract class HttpObjectDecoder extends ReplayingDecoder { @Override protected void encodeInitialLine(ByteBuf buf, HttpRequest request) throws Exception { - request.getMethod().encode(buf); + request.method().encode(buf); buf.writeByte(SP); // Add / as absolute path if no is present. // See http://tools.ietf.org/html/rfc2616#section-5.1.2 - String uri = request.getUri(); + String uri = request.uri(); if (uri.length() == 0) { uri += SLASH; @@ -57,7 +57,7 @@ public class HttpRequestEncoder extends HttpObjectEncoder { buf.writeBytes(uri.getBytes(CharsetUtil.UTF_8)); buf.writeByte(SP); - request.getProtocolVersion().encode(buf); + request.protocolVersion().encode(buf); buf.writeBytes(CRLF); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponse.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponse.java index 7c7ebe2427..44cb77e361 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponse.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponse.java @@ -31,12 +31,18 @@ package io.netty.handler.codec.http; */ public interface HttpResponse extends HttpMessage { + /** + * @deprecated Use {@link #status()} instead. + */ + @Deprecated + HttpResponseStatus getStatus(); + /** * Returns the status of this {@link HttpResponse}. * * @return The {@link HttpResponseStatus} of this {@link HttpResponse} */ - HttpResponseStatus getStatus(); + HttpResponseStatus status(); /** * Set the status of this {@link HttpResponse}. diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponseEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponseEncoder.java index 07e2414998..5a4c7c5cc3 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponseEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpResponseEncoder.java @@ -33,9 +33,9 @@ public class HttpResponseEncoder extends HttpObjectEncoder { @Override protected void encodeInitialLine(ByteBuf buf, HttpResponse response) throws Exception { - response.getProtocolVersion().encode(buf); + response.protocolVersion().encode(buf); buf.writeByte(SP); - response.getStatus().encode(buf); + response.status().encode(buf); buf.writeBytes(CRLF); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/LastHttpContent.java b/codec-http/src/main/java/io/netty/handler/codec/http/LastHttpContent.java index d93d1d1865..518e31fe22 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/LastHttpContent.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/LastHttpContent.java @@ -50,6 +50,12 @@ public interface LastHttpContent extends HttpContent { } @Override + public DecoderResult decoderResult() { + return DecoderResult.SUCCESS; + } + + @Override + @Deprecated public DecoderResult getDecoderResult() { return DecoderResult.SUCCESS; } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java index 91d8aca98c..eabdcfbf8f 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringDecoder.java @@ -301,9 +301,7 @@ public class QueryStringDecoder { * @throws IllegalArgumentException if the string contains a malformed * escape sequence. */ - @SuppressWarnings("fallthrough") - public static String decodeComponent(final String s, - final Charset charset) { + public static String decodeComponent(final String s, final Charset charset) { if (s == null) { return ""; } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringEncoder.java index 15eeeebadc..86d5ac6c5c 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/QueryStringEncoder.java @@ -114,7 +114,7 @@ public class QueryStringEncoder { // TODO: Optimize me. try { return URLEncoder.encode(s, charset.name()).replace("+", "%20"); - } catch (UnsupportedEncodingException e) { + } catch (UnsupportedEncodingException ignored) { throw new UnsupportedCharsetException(charset.name()); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/ServerCookieEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/ServerCookieEncoder.java index b49a033a53..3c71ddcc66 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/ServerCookieEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/ServerCookieEncoder.java @@ -49,32 +49,32 @@ public final class ServerCookieEncoder { StringBuilder buf = stringBuilder(); - add(buf, cookie.getName(), cookie.getValue()); + add(buf, cookie.name(), cookie.value()); - if (cookie.getMaxAge() != Long.MIN_VALUE) { - if (cookie.getVersion() == 0) { + if (cookie.maxAge() != Long.MIN_VALUE) { + if (cookie.version() == 0) { addUnquoted(buf, CookieHeaderNames.EXPIRES, HttpHeaderDateFormat.get().format( new Date(System.currentTimeMillis() + - cookie.getMaxAge() * 1000L))); + cookie.maxAge() * 1000L))); } else { - add(buf, CookieHeaderNames.MAX_AGE, cookie.getMaxAge()); + add(buf, CookieHeaderNames.MAX_AGE, cookie.maxAge()); } } - if (cookie.getPath() != null) { - if (cookie.getVersion() > 0) { - add(buf, CookieHeaderNames.PATH, cookie.getPath()); + if (cookie.path() != null) { + if (cookie.version() > 0) { + add(buf, CookieHeaderNames.PATH, cookie.path()); } else { - addUnquoted(buf, CookieHeaderNames.PATH, cookie.getPath()); + addUnquoted(buf, CookieHeaderNames.PATH, cookie.path()); } } - if (cookie.getDomain() != null) { - if (cookie.getVersion() > 0) { - add(buf, CookieHeaderNames.DOMAIN, cookie.getDomain()); + if (cookie.domain() != null) { + if (cookie.version() > 0) { + add(buf, CookieHeaderNames.DOMAIN, cookie.domain()); } else { - addUnquoted(buf, CookieHeaderNames.DOMAIN, cookie.getDomain()); + addUnquoted(buf, CookieHeaderNames.DOMAIN, cookie.domain()); } } if (cookie.isSecure()) { @@ -87,22 +87,22 @@ public final class ServerCookieEncoder { buf.append((char) HttpConstants.SEMICOLON); buf.append((char) HttpConstants.SP); } - if (cookie.getVersion() >= 1) { - if (cookie.getComment() != null) { - add(buf, CookieHeaderNames.COMMENT, cookie.getComment()); + if (cookie.version() >= 1) { + if (cookie.comment() != null) { + add(buf, CookieHeaderNames.COMMENT, cookie.comment()); } add(buf, CookieHeaderNames.VERSION, 1); - if (cookie.getCommentUrl() != null) { - addQuoted(buf, CookieHeaderNames.COMMENTURL, cookie.getCommentUrl()); + if (cookie.commentUrl() != null) { + addQuoted(buf, CookieHeaderNames.COMMENTURL, cookie.commentUrl()); } - if (!cookie.getPorts().isEmpty()) { + if (!cookie.ports().isEmpty()) { buf.append(CookieHeaderNames.PORT); buf.append((char) HttpConstants.EQUALS); buf.append((char) HttpConstants.DOUBLE_QUOTE); - for (int port: cookie.getPorts()) { + for (int port: cookie.ports()) { buf.append(port); buf.append((char) HttpConstants.COMMA); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsHandler.java index fa16ac0859..dea12c83ce 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsHandler.java @@ -64,7 +64,7 @@ public class CorsHandler extends ChannelDuplexHandler { } private void handlePreflight(final ChannelHandlerContext ctx, final HttpRequest request) { - final HttpResponse response = new DefaultFullHttpResponse(request.getProtocolVersion(), OK); + final HttpResponse response = new DefaultFullHttpResponse(request.protocolVersion(), OK); if (setOrigin(response)) { setAllowMethods(response); setAllowHeaders(response); @@ -153,7 +153,7 @@ public class CorsHandler extends ChannelDuplexHandler { private static boolean isPreflightRequest(final HttpRequest request) { final HttpHeaders headers = request.headers(); - return request.getMethod().equals(OPTIONS) && + return request.method().equals(OPTIONS) && headers.contains(ORIGIN) && headers.contains(ACCESS_CONTROL_REQUEST_METHOD); } @@ -197,7 +197,7 @@ public class CorsHandler extends ChannelDuplexHandler { } private static void forbidden(final ChannelHandlerContext ctx, final HttpRequest request) { - ctx.writeAndFlush(new DefaultFullHttpResponse(request.getProtocolVersion(), FORBIDDEN)) + ctx.writeAndFlush(new DefaultFullHttpResponse(request.protocolVersion(), FORBIDDEN)) .addListener(ChannelFutureListener.CLOSE); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/CaseIgnoringComparator.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/CaseIgnoringComparator.java index afccf26079..6f86d3f911 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/CaseIgnoringComparator.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/CaseIgnoringComparator.java @@ -32,7 +32,6 @@ final class CaseIgnoringComparator implements Comparator, Serializable { return o1.compareToIgnoreCase(o2); } - @SuppressWarnings("MethodMayBeStatic") private Object readResolve() { return INSTANCE; } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java index 4765485348..b4ba99ff59 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java @@ -188,7 +188,7 @@ public class HttpPostRequestEncoder implements ChunkedInput { if (charset == null) { throw new NullPointerException("charset"); } - if (request.getMethod() != HttpMethod.POST) { + if (request.method() != HttpMethod.POST) { throw new ErrorDataEncoderException("Cannot create a Encoder if not a POST"); } this.request = request; @@ -1116,17 +1116,32 @@ public class HttpPostRequestEncoder implements ChunkedInput { @Override public HttpMethod getMethod() { - return request.getMethod(); + return request.method(); + } + + @Override + public HttpMethod method() { + return request.method(); } @Override public String getUri() { - return request.getUri(); + return request.uri(); + } + + @Override + public String uri() { + return request.uri(); } @Override public HttpVersion getProtocolVersion() { - return request.getProtocolVersion(); + return request.protocolVersion(); + } + + @Override + public HttpVersion protocolVersion() { + return request.protocolVersion(); } @Override @@ -1135,8 +1150,14 @@ public class HttpPostRequestEncoder implements ChunkedInput { } @Override + public DecoderResult decoderResult() { + return request.decoderResult(); + } + + @Override + @Deprecated public DecoderResult getDecoderResult() { - return request.getDecoderResult(); + return request.decoderResult(); } @Override diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java index 846b12077a..c4a4cce17d 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocket08FrameDecoder.java @@ -331,7 +331,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder { @Override protected void encodeInitialLine(ByteBuf buf, HttpRequest request) throws Exception { - encodeAscii(request.getMethod().toString(), buf); + encodeAscii(request.method().toString(), buf); buf.writeByte(SP); - buf.writeBytes(request.getUri().getBytes(CharsetUtil.UTF_8)); + buf.writeBytes(request.uri().getBytes(CharsetUtil.UTF_8)); buf.writeByte(SP); - encodeAscii(request.getProtocolVersion().toString(), buf); + encodeAscii(request.protocolVersion().toString(), buf); buf.writeBytes(CRLF); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspResponseEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspResponseEncoder.java index 3474901267..33d71c5e6c 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspResponseEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspResponseEncoder.java @@ -38,11 +38,11 @@ public class RtspResponseEncoder extends RtspObjectEncoder { @Override protected void encodeInitialLine(ByteBuf buf, HttpResponse response) throws Exception { - encodeAscii(response.getProtocolVersion().toString(), buf); + encodeAscii(response.protocolVersion().toString(), buf); buf.writeByte(SP); - buf.writeBytes(String.valueOf(response.getStatus().code()).getBytes(CharsetUtil.US_ASCII)); + buf.writeBytes(String.valueOf(response.status().code()).getBytes(CharsetUtil.US_ASCII)); buf.writeByte(SP); - encodeAscii(String.valueOf(response.getStatus().reasonPhrase()), buf); + encodeAscii(String.valueOf(response.status().reasonPhrase()), buf); buf.writeBytes(CRLF); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyDataFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyDataFrame.java index cfdb1d07cb..cea87d626f 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyDataFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyDataFrame.java @@ -80,14 +80,14 @@ public class DefaultSpdyDataFrame extends DefaultSpdyStreamFrame implements Spdy @Override public SpdyDataFrame copy() { - SpdyDataFrame frame = new DefaultSpdyDataFrame(getStreamId(), content().copy()); + SpdyDataFrame frame = new DefaultSpdyDataFrame(streamId(), content().copy()); frame.setLast(isLast()); return frame; } @Override public SpdyDataFrame duplicate() { - SpdyDataFrame frame = new DefaultSpdyDataFrame(getStreamId(), content().duplicate()); + SpdyDataFrame frame = new DefaultSpdyDataFrame(streamId(), content().duplicate()); frame.setLast(isLast()); return frame; } @@ -128,7 +128,7 @@ public class DefaultSpdyDataFrame extends DefaultSpdyStreamFrame implements Spdy buf.append(')'); buf.append(StringUtil.NEWLINE); buf.append("--> Stream-ID = "); - buf.append(getStreamId()); + buf.append(streamId()); buf.append(StringUtil.NEWLINE); buf.append("--> Size = "); if (refCnt() == 0) { diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyGoAwayFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyGoAwayFrame.java index c4515f51ac..5e79783b0a 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyGoAwayFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyGoAwayFrame.java @@ -56,7 +56,13 @@ public class DefaultSpdyGoAwayFrame implements SpdyGoAwayFrame { } @Override + @Deprecated public int getLastGoodStreamId() { + return lastGoodStreamId(); + } + + @Override + public int lastGoodStreamId() { return lastGoodStreamId; } @@ -71,7 +77,13 @@ public class DefaultSpdyGoAwayFrame implements SpdyGoAwayFrame { } @Override + @Deprecated public SpdySessionStatus getStatus() { + return status(); + } + + @Override + public SpdySessionStatus status() { return status; } @@ -87,10 +99,10 @@ public class DefaultSpdyGoAwayFrame implements SpdyGoAwayFrame { buf.append(StringUtil.simpleClassName(this)); buf.append(StringUtil.NEWLINE); buf.append("--> Last-good-stream-ID = "); - buf.append(getLastGoodStreamId()); + buf.append(lastGoodStreamId()); buf.append(StringUtil.NEWLINE); buf.append("--> Status: "); - buf.append(getStatus().toString()); + buf.append(status()); return buf.toString(); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyHeadersFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyHeadersFrame.java index e614c18075..65c05ebdad 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyHeadersFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyHeadersFrame.java @@ -86,7 +86,7 @@ public class DefaultSpdyHeadersFrame extends DefaultSpdyStreamFrame buf.append(')'); buf.append(StringUtil.NEWLINE); buf.append("--> Stream-ID = "); - buf.append(getStreamId()); + buf.append(streamId()); buf.append(StringUtil.NEWLINE); buf.append("--> Headers:"); buf.append(StringUtil.NEWLINE); diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyPingFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyPingFrame.java index 667fa0eccc..7f697d53ad 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyPingFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyPingFrame.java @@ -34,7 +34,13 @@ public class DefaultSpdyPingFrame implements SpdyPingFrame { } @Override + @Deprecated public int getId() { + return id(); + } + + @Override + public int id() { return id; } @@ -50,7 +56,7 @@ public class DefaultSpdyPingFrame implements SpdyPingFrame { buf.append(StringUtil.simpleClassName(this)); buf.append(StringUtil.NEWLINE); buf.append("--> ID = "); - buf.append(getId()); + buf.append(id()); return buf.toString(); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyRstStreamFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyRstStreamFrame.java index ee58491743..a8874bd8aa 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyRstStreamFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyRstStreamFrame.java @@ -59,7 +59,13 @@ public class DefaultSpdyRstStreamFrame extends DefaultSpdyStreamFrame } @Override + @Deprecated public SpdyStreamStatus getStatus() { + return status(); + } + + @Override + public SpdyStreamStatus status() { return status; } @@ -75,10 +81,10 @@ public class DefaultSpdyRstStreamFrame extends DefaultSpdyStreamFrame buf.append(StringUtil.simpleClassName(this)); buf.append(StringUtil.NEWLINE); buf.append("--> Stream-ID = "); - buf.append(getStreamId()); + buf.append(streamId()); buf.append(StringUtil.NEWLINE); buf.append("--> Status: "); - buf.append(getStatus().toString()); + buf.append(status()); return buf.toString(); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySettingsFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySettingsFrame.java index 7a9b2072a5..505b3713cb 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySettingsFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySettingsFrame.java @@ -30,7 +30,13 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame { private final Map settingsMap = new TreeMap(); @Override + @Deprecated public Set getIds() { + return ids(); + } + + @Override + public Set ids() { return settingsMap.keySet(); } @@ -138,7 +144,7 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame { for (Map.Entry e: getSettings()) { Setting setting = e.getValue(); buf.append("--> "); - buf.append(e.getKey().toString()); + buf.append(e.getKey()); buf.append(':'); buf.append(setting.getValue()); buf.append(" (persist value: "); diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyStreamFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyStreamFrame.java index 4d7608a5d1..7a8b94e1df 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyStreamFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyStreamFrame.java @@ -33,7 +33,13 @@ public abstract class DefaultSpdyStreamFrame implements SpdyStreamFrame { } @Override + @Deprecated public int getStreamId() { + return streamId(); + } + + @Override + public int streamId() { return streamId; } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySynReplyFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySynReplyFrame.java index 331c3e818e..b9fafab008 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySynReplyFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySynReplyFrame.java @@ -59,7 +59,7 @@ public class DefaultSpdySynReplyFrame extends DefaultSpdyHeadersFrame buf.append(')'); buf.append(StringUtil.NEWLINE); buf.append("--> Stream-ID = "); - buf.append(getStreamId()); + buf.append(streamId()); buf.append(StringUtil.NEWLINE); buf.append("--> Headers:"); buf.append(StringUtil.NEWLINE); diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySynStreamFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySynStreamFrame.java index ea97dc11e3..a394770dda 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySynStreamFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdySynStreamFrame.java @@ -23,21 +23,20 @@ import io.netty.util.internal.StringUtil; public class DefaultSpdySynStreamFrame extends DefaultSpdyHeadersFrame implements SpdySynStreamFrame { - private int associatedToStreamId; + private int associatedStreamId; private byte priority; private boolean unidirectional; /** * Creates a new instance. * - * @param streamId the Stream-ID of this frame - * @param associatedToStreamId the Associated-To-Stream-ID of this frame - * @param priority the priority of the stream + * @param streamId the Stream-ID of this frame + * @param associatedStreamId the Associated-To-Stream-ID of this frame + * @param priority the priority of the stream */ - public DefaultSpdySynStreamFrame( - int streamId, int associatedToStreamId, byte priority) { + public DefaultSpdySynStreamFrame(int streamId, int associatedStreamId, byte priority) { super(streamId); - setAssociatedToStreamId(associatedToStreamId); + setAssociatedStreamId(associatedStreamId); setPriority(priority); } @@ -60,23 +59,41 @@ public class DefaultSpdySynStreamFrame extends DefaultSpdyHeadersFrame } @Override + @Deprecated public int getAssociatedToStreamId() { - return associatedToStreamId; + return associatedStreamId(); } @Override + public int associatedStreamId() { + return associatedStreamId; + } + + @Override + @Deprecated public SpdySynStreamFrame setAssociatedToStreamId(int associatedToStreamId) { - if (associatedToStreamId < 0) { + return setAssociatedStreamId(associatedToStreamId); + } + + @Override + public SpdySynStreamFrame setAssociatedStreamId(int associatedStreamId) { + if (associatedStreamId < 0) { throw new IllegalArgumentException( "Associated-To-Stream-ID cannot be negative: " + - associatedToStreamId); + associatedStreamId); } - this.associatedToStreamId = associatedToStreamId; + this.associatedStreamId = associatedStreamId; return this; } @Override + @Deprecated public byte getPriority() { + return priority(); + } + + @Override + public byte priority() { return priority; } @@ -112,15 +129,15 @@ public class DefaultSpdySynStreamFrame extends DefaultSpdyHeadersFrame buf.append(')'); buf.append(StringUtil.NEWLINE); buf.append("--> Stream-ID = "); - buf.append(getStreamId()); + buf.append(streamId()); buf.append(StringUtil.NEWLINE); - if (associatedToStreamId != 0) { + if (associatedStreamId != 0) { buf.append("--> Associated-To-Stream-ID = "); - buf.append(getAssociatedToStreamId()); + buf.append(associatedStreamId()); buf.append(StringUtil.NEWLINE); } buf.append("--> Priority = "); - buf.append(getPriority()); + buf.append(priority()); buf.append(StringUtil.NEWLINE); buf.append("--> Headers:"); buf.append(StringUtil.NEWLINE); diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyWindowUpdateFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyWindowUpdateFrame.java index 08833a5f63..1ec8672af8 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyWindowUpdateFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/DefaultSpdyWindowUpdateFrame.java @@ -37,7 +37,13 @@ public class DefaultSpdyWindowUpdateFrame implements SpdyWindowUpdateFrame { } @Override + @Deprecated public int getStreamId() { + return streamId(); + } + + @Override + public int streamId() { return streamId; } @@ -52,7 +58,13 @@ public class DefaultSpdyWindowUpdateFrame implements SpdyWindowUpdateFrame { } @Override + @Deprecated public int getDeltaWindowSize() { + return deltaWindowSize(); + } + + @Override + public int deltaWindowSize() { return deltaWindowSize; } @@ -73,10 +85,10 @@ public class DefaultSpdyWindowUpdateFrame implements SpdyWindowUpdateFrame { buf.append(StringUtil.simpleClassName(this)); buf.append(StringUtil.NEWLINE); buf.append("--> Stream-ID = "); - buf.append(getStreamId()); + buf.append(streamId()); buf.append(StringUtil.NEWLINE); buf.append("--> Delta-Window-Size = "); - buf.append(getDeltaWindowSize()); + buf.append(deltaWindowSize()); return buf.toString(); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameCodec.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameCodec.java index 7a15d8014b..936432e1cf 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameCodec.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameCodec.java @@ -140,7 +140,7 @@ public class SpdyFrameCodec extends ByteToMessageDecoder SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg; frame = spdyFrameEncoder.encodeDataFrame( ctx.alloc(), - spdyDataFrame.getStreamId(), + spdyDataFrame.streamId(), spdyDataFrame.isLast(), spdyDataFrame.content() ); @@ -154,9 +154,9 @@ public class SpdyFrameCodec extends ByteToMessageDecoder try { frame = spdyFrameEncoder.encodeSynStreamFrame( ctx.alloc(), - spdySynStreamFrame.getStreamId(), - spdySynStreamFrame.getAssociatedToStreamId(), - spdySynStreamFrame.getPriority(), + spdySynStreamFrame.streamId(), + spdySynStreamFrame.associatedStreamId(), + spdySynStreamFrame.priority(), spdySynStreamFrame.isLast(), spdySynStreamFrame.isUnidirectional(), headerBlock @@ -173,7 +173,7 @@ public class SpdyFrameCodec extends ByteToMessageDecoder try { frame = spdyFrameEncoder.encodeSynReplyFrame( ctx.alloc(), - spdySynReplyFrame.getStreamId(), + spdySynReplyFrame.streamId(), spdySynReplyFrame.isLast(), headerBlock ); @@ -187,8 +187,8 @@ public class SpdyFrameCodec extends ByteToMessageDecoder SpdyRstStreamFrame spdyRstStreamFrame = (SpdyRstStreamFrame) msg; frame = spdyFrameEncoder.encodeRstStreamFrame( ctx.alloc(), - spdyRstStreamFrame.getStreamId(), - spdyRstStreamFrame.getStatus().getCode() + spdyRstStreamFrame.streamId(), + spdyRstStreamFrame.status().code() ); ctx.write(frame, promise); @@ -206,7 +206,7 @@ public class SpdyFrameCodec extends ByteToMessageDecoder SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg; frame = spdyFrameEncoder.encodePingFrame( ctx.alloc(), - spdyPingFrame.getId() + spdyPingFrame.id() ); ctx.write(frame, promise); @@ -215,8 +215,8 @@ public class SpdyFrameCodec extends ByteToMessageDecoder SpdyGoAwayFrame spdyGoAwayFrame = (SpdyGoAwayFrame) msg; frame = spdyFrameEncoder.encodeGoAwayFrame( ctx.alloc(), - spdyGoAwayFrame.getLastGoodStreamId(), - spdyGoAwayFrame.getStatus().getCode() + spdyGoAwayFrame.lastGoodStreamId(), + spdyGoAwayFrame.status().code() ); ctx.write(frame, promise); @@ -227,7 +227,7 @@ public class SpdyFrameCodec extends ByteToMessageDecoder try { frame = spdyFrameEncoder.encodeHeadersFrame( ctx.alloc(), - spdyHeadersFrame.getStreamId(), + spdyHeadersFrame.streamId(), spdyHeadersFrame.isLast(), headerBlock ); @@ -241,8 +241,8 @@ public class SpdyFrameCodec extends ByteToMessageDecoder SpdyWindowUpdateFrame spdyWindowUpdateFrame = (SpdyWindowUpdateFrame) msg; frame = spdyFrameEncoder.encodeWindowUpdateFrame( ctx.alloc(), - spdyWindowUpdateFrame.getStreamId(), - spdyWindowUpdateFrame.getDeltaWindowSize() + spdyWindowUpdateFrame.streamId(), + spdyWindowUpdateFrame.deltaWindowSize() ); ctx.write(frame, promise); } else { diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameEncoder.java index 636480150a..1524f95234 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyFrameEncoder.java @@ -97,7 +97,7 @@ public class SpdyFrameEncoder { } public ByteBuf encodeSettingsFrame(ByteBufAllocator allocator, SpdySettingsFrame spdySettingsFrame) { - Set ids = spdySettingsFrame.getIds(); + Set ids = spdySettingsFrame.ids(); int numSettings = ids.size(); byte flags = spdySettingsFrame.clearPreviouslyPersistedSettings() ? diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyGoAwayFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyGoAwayFrame.java index 318c6bfe92..e1f7e1bcf0 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyGoAwayFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyGoAwayFrame.java @@ -20,10 +20,16 @@ package io.netty.handler.codec.spdy; */ public interface SpdyGoAwayFrame extends SpdyFrame { + /** + * @deprecated Use {@link #lastGoodStreamId()} instead. + */ + @Deprecated + int getLastGoodStreamId(); + /** * Returns the Last-good-stream-ID of this frame. */ - int getLastGoodStreamId(); + int lastGoodStreamId(); /** * Sets the Last-good-stream-ID of this frame. The Last-good-stream-ID @@ -31,10 +37,16 @@ public interface SpdyGoAwayFrame extends SpdyFrame { */ SpdyGoAwayFrame setLastGoodStreamId(int lastGoodStreamId); + /** + * @deprecated Use {@link #status()} instead. + */ + @Deprecated + SpdySessionStatus getStatus(); + /** * Returns the status of this frame. */ - SpdySessionStatus getStatus(); + SpdySessionStatus status(); /** * Sets the status of this frame. diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockRawDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockRawDecoder.java index 750d1f4f6f..2e1a02c172 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockRawDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockRawDecoder.java @@ -51,7 +51,7 @@ public class SpdyHeaderBlockRawDecoder extends SpdyHeaderBlockDecoder { throw new NullPointerException("spdyVersion"); } this.maxHeaderSize = maxHeaderSize; - this.state = State.READ_NUM_HEADERS; + state = State.READ_NUM_HEADERS; } private static int readLengthField(ByteBuf buffer) { diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibDecoder.java index dffa26b163..44e7d52ffb 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockZlibDecoder.java @@ -79,14 +79,14 @@ final class SpdyHeaderBlockZlibDecoder extends SpdyHeaderBlockRawDecoder { if (numBytes == 0 && decompressor.needsDictionary()) { try { decompressor.setDictionary(SPDY_DICT); - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException ignored) { throw INVALID_HEADER_BLOCK; } numBytes = decompressor.inflate(out, off, decompressed.writableBytes()); } if (frame != null) { decompressed.writerIndex(decompressed.writerIndex() + numBytes); - super.decodeHeaderBlock(decompressed, frame); + decodeHeaderBlock(decompressed, frame); decompressed.discardReadBytes(); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java index 6ad8cf2a95..e8c32b5b86 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpDecoder.java @@ -96,11 +96,11 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { // HTTP requests/responses are mapped one-to-one to SPDY streams. SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg; - int streamId = spdySynStreamFrame.getStreamId(); + int streamId = spdySynStreamFrame.streamId(); if (SpdyCodecUtil.isServerId(streamId)) { // SYN_STREAM frames initiated by the server are pushed resources - int associatedToStreamId = spdySynStreamFrame.getAssociatedToStreamId(); + int associatedToStreamId = spdySynStreamFrame.associatedStreamId(); // If a client receives a SYN_STREAM with an Associated-To-Stream-ID of 0 // it must reply with a RST_STREAM with error code INVALID_STREAM @@ -138,7 +138,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { // Set the Stream-ID, Associated-To-Stream-ID, Priority, and URL as headers SpdyHttpHeaders.setStreamId(httpResponseWithEntity, streamId); SpdyHttpHeaders.setAssociatedToStreamId(httpResponseWithEntity, associatedToStreamId); - SpdyHttpHeaders.setPriority(httpResponseWithEntity, spdySynStreamFrame.getPriority()); + SpdyHttpHeaders.setPriority(httpResponseWithEntity, spdySynStreamFrame.priority()); SpdyHttpHeaders.setUrl(httpResponseWithEntity, URL); if (spdySynStreamFrame.isLast()) { @@ -196,7 +196,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { } else if (msg instanceof SpdySynReplyFrame) { SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg; - int streamId = spdySynReplyFrame.getStreamId(); + int streamId = spdySynReplyFrame.streamId(); // If a client receives a SYN_REPLY with a truncated header block, // reply with a RST_STREAM frame with error code INTERNAL_ERROR. @@ -231,7 +231,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { } else if (msg instanceof SpdyHeadersFrame) { SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg; - int streamId = spdyHeadersFrame.getStreamId(); + int streamId = spdyHeadersFrame.streamId(); FullHttpMessage fullHttpMessage = getMessage(streamId); // If message is not in map discard HEADERS frame. @@ -255,7 +255,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { } else if (msg instanceof SpdyDataFrame) { SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg; - int streamId = spdyDataFrame.getStreamId(); + int streamId = spdyDataFrame.streamId(); FullHttpMessage fullHttpMessage = getMessage(streamId); // If message is not in map discard Data Frame. @@ -283,7 +283,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder { } else if (msg instanceof SpdyRstStreamFrame) { SpdyRstStreamFrame spdyRstStreamFrame = (SpdyRstStreamFrame) msg; - int streamId = spdyRstStreamFrame.getStreamId(); + int streamId = spdyRstStreamFrame.streamId(); removeMessage(streamId); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpEncoder.java index 111f9c1ccd..23d5aea282 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpEncoder.java @@ -229,15 +229,15 @@ public class SpdyHttpEncoder extends MessageToMessageEncoder { // Unfold the first line of the message into name/value pairs if (httpMessage instanceof FullHttpRequest) { HttpRequest httpRequest = (HttpRequest) httpMessage; - SpdyHeaders.setMethod(spdyVersion, spdySynStreamFrame, httpRequest.getMethod()); - SpdyHeaders.setUrl(spdyVersion, spdySynStreamFrame, httpRequest.getUri()); - SpdyHeaders.setVersion(spdyVersion, spdySynStreamFrame, httpMessage.getProtocolVersion()); + SpdyHeaders.setMethod(spdyVersion, spdySynStreamFrame, httpRequest.method()); + SpdyHeaders.setUrl(spdyVersion, spdySynStreamFrame, httpRequest.uri()); + SpdyHeaders.setVersion(spdyVersion, spdySynStreamFrame, httpMessage.protocolVersion()); } if (httpMessage instanceof HttpResponse) { HttpResponse httpResponse = (HttpResponse) httpMessage; - SpdyHeaders.setStatus(spdyVersion, spdySynStreamFrame, httpResponse.getStatus()); + SpdyHeaders.setStatus(spdyVersion, spdySynStreamFrame, httpResponse.status()); SpdyHeaders.setUrl(spdyVersion, spdySynStreamFrame, URL); - SpdyHeaders.setVersion(spdyVersion, spdySynStreamFrame, httpMessage.getProtocolVersion()); + SpdyHeaders.setVersion(spdyVersion, spdySynStreamFrame, httpMessage.protocolVersion()); spdySynStreamFrame.setUnidirectional(true); } @@ -258,7 +258,7 @@ public class SpdyHttpEncoder extends MessageToMessageEncoder { for (Map.Entry entry: httpMessage.headers()) { spdySynStreamFrame.headers().add(entry.getKey(), entry.getValue()); } - currentStreamId = spdySynStreamFrame.getStreamId(); + currentStreamId = spdySynStreamFrame.streamId(); spdySynStreamFrame.setLast(isLast(httpMessage)); return spdySynStreamFrame; @@ -280,8 +280,8 @@ public class SpdyHttpEncoder extends MessageToMessageEncoder { SpdySynReplyFrame spdySynReplyFrame = new DefaultSpdySynReplyFrame(streamID); // Unfold the first line of the response into name/value pairs - SpdyHeaders.setStatus(spdyVersion, spdySynReplyFrame, httpResponse.getStatus()); - SpdyHeaders.setVersion(spdyVersion, spdySynReplyFrame, httpResponse.getProtocolVersion()); + SpdyHeaders.setStatus(spdyVersion, spdySynReplyFrame, httpResponse.status()); + SpdyHeaders.setVersion(spdyVersion, spdySynReplyFrame, httpResponse.protocolVersion()); // Transfer the remaining HTTP headers for (Map.Entry entry: httpResponse.headers()) { diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpResponseStreamIdHandler.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpResponseStreamIdHandler.java index 51834a281c..493b922e64 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpResponseStreamIdHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHttpResponseStreamIdHandler.java @@ -59,7 +59,7 @@ public class SpdyHttpResponseStreamIdHandler extends ids.add(SpdyHttpHeaders.getStreamId((HttpMessage) msg)); } } else if (msg instanceof SpdyRstStreamFrame) { - ids.remove(((SpdyRstStreamFrame) msg).getStreamId()); + ids.remove(((SpdyRstStreamFrame) msg).streamId()); } out.add(ReferenceCountUtil.retain(msg)); diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyPingFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyPingFrame.java index d2e98e67b9..0bc947148d 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyPingFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyPingFrame.java @@ -20,10 +20,16 @@ package io.netty.handler.codec.spdy; */ public interface SpdyPingFrame extends SpdyFrame { + /** + * @deprecated Use {@link #id()} instead. + */ + @Deprecated + int getId(); + /** * Returns the ID of this frame. */ - int getId(); + int id(); /** * Sets the ID of this frame. diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyRstStreamFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyRstStreamFrame.java index fbab068e8d..f3924671d4 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyRstStreamFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyRstStreamFrame.java @@ -20,10 +20,16 @@ package io.netty.handler.codec.spdy; */ public interface SpdyRstStreamFrame extends SpdyStreamFrame { + /** + * @deprecated Use {@link #status()} instead. + */ + @Deprecated + SpdyStreamStatus getStatus(); + /** * Returns the status of this frame. */ - SpdyStreamStatus getStatus(); + SpdyStreamStatus status(); /** * Sets the status of this frame. diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySession.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySession.java index 0cd1ec6852..6c6a5a3408 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySession.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySession.java @@ -37,7 +37,7 @@ final class SpdySession { private final AtomicInteger sendWindowSize; private final AtomicInteger receiveWindowSize; - public SpdySession(int sendWindowSize, int receiveWindowSize) { + SpdySession(int sendWindowSize, int receiveWindowSize) { this.sendWindowSize = new AtomicInteger(sendWindowSize); this.receiveWindowSize = new AtomicInteger(receiveWindowSize); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java index 1dd3add864..ccff2a706e 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java @@ -24,7 +24,7 @@ import io.netty.util.internal.EmptyArrays; import java.util.concurrent.atomic.AtomicInteger; -import static io.netty.handler.codec.spdy.SpdyCodecUtil.SPDY_SESSION_STREAM_ID; +import static io.netty.handler.codec.spdy.SpdyCodecUtil.*; /** * Manages streams within a SPDY session. @@ -121,7 +121,7 @@ public class SpdySessionHandler * a RST_STREAM frame with the getStatus PROTOCOL_ERROR. */ SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg; - int streamId = spdyDataFrame.getStreamId(); + int streamId = spdyDataFrame.streamId(); int deltaWindowSize = -1 * spdyDataFrame.content().readableBytes(); int newSessionWindowSize = @@ -230,7 +230,7 @@ public class SpdySessionHandler */ SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg; - int streamId = spdySynStreamFrame.getStreamId(); + int streamId = spdySynStreamFrame.streamId(); // Check if we received a valid SYN_STREAM frame if (spdySynStreamFrame.isInvalid() || @@ -247,7 +247,7 @@ public class SpdySessionHandler } // Try to accept the stream - byte priority = spdySynStreamFrame.getPriority(); + byte priority = spdySynStreamFrame.priority(); boolean remoteSideClosed = spdySynStreamFrame.isLast(); boolean localSideClosed = spdySynStreamFrame.isUnidirectional(); if (!acceptStream(streamId, priority, remoteSideClosed, localSideClosed)) { @@ -265,7 +265,7 @@ public class SpdySessionHandler */ SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg; - int streamId = spdySynReplyFrame.getStreamId(); + int streamId = spdySynReplyFrame.streamId(); // Check if we received a valid SYN_REPLY frame if (spdySynReplyFrame.isInvalid() || @@ -300,7 +300,7 @@ public class SpdySessionHandler */ SpdyRstStreamFrame spdyRstStreamFrame = (SpdyRstStreamFrame) msg; - removeStream(spdyRstStreamFrame.getStreamId(), ctx.newSucceededFuture()); + removeStream(spdyRstStreamFrame.streamId(), ctx.newSucceededFuture()); } else if (msg instanceof SpdySettingsFrame) { @@ -346,7 +346,7 @@ public class SpdySessionHandler SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg; - if (isRemoteInitiatedId(spdyPingFrame.getId())) { + if (isRemoteInitiatedId(spdyPingFrame.id())) { ctx.writeAndFlush(spdyPingFrame); return; } @@ -364,7 +364,7 @@ public class SpdySessionHandler } else if (msg instanceof SpdyHeadersFrame) { SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg; - int streamId = spdyHeadersFrame.getStreamId(); + int streamId = spdyHeadersFrame.streamId(); // Check if we received a valid HEADERS frame if (spdyHeadersFrame.isInvalid()) { @@ -395,8 +395,8 @@ public class SpdySessionHandler */ SpdyWindowUpdateFrame spdyWindowUpdateFrame = (SpdyWindowUpdateFrame) msg; - int streamId = spdyWindowUpdateFrame.getStreamId(); - int deltaWindowSize = spdyWindowUpdateFrame.getDeltaWindowSize(); + int streamId = spdyWindowUpdateFrame.streamId(); + int deltaWindowSize = spdyWindowUpdateFrame.deltaWindowSize(); // Ignore frames for half-closed streams if (streamId != SPDY_SESSION_STREAM_ID && spdySession.isLocalSideClosed(streamId)) { @@ -463,7 +463,7 @@ public class SpdySessionHandler if (msg instanceof SpdyDataFrame) { SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg; - int streamId = spdyDataFrame.getStreamId(); + int streamId = spdyDataFrame.streamId(); // Frames must not be sent on half-closed streams if (spdySession.isLocalSideClosed(streamId)) { @@ -546,14 +546,14 @@ public class SpdySessionHandler } else if (msg instanceof SpdySynStreamFrame) { SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg; - int streamId = spdySynStreamFrame.getStreamId(); + int streamId = spdySynStreamFrame.streamId(); if (isRemoteInitiatedId(streamId)) { promise.setFailure(PROTOCOL_EXCEPTION); return; } - byte priority = spdySynStreamFrame.getPriority(); + byte priority = spdySynStreamFrame.priority(); boolean remoteSideClosed = spdySynStreamFrame.isUnidirectional(); boolean localSideClosed = spdySynStreamFrame.isLast(); if (!acceptStream(streamId, priority, remoteSideClosed, localSideClosed)) { @@ -564,7 +564,7 @@ public class SpdySessionHandler } else if (msg instanceof SpdySynReplyFrame) { SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg; - int streamId = spdySynReplyFrame.getStreamId(); + int streamId = spdySynReplyFrame.streamId(); // Frames must not be sent on half-closed streams if (!isRemoteInitiatedId(streamId) || spdySession.isLocalSideClosed(streamId)) { @@ -580,7 +580,7 @@ public class SpdySessionHandler } else if (msg instanceof SpdyRstStreamFrame) { SpdyRstStreamFrame spdyRstStreamFrame = (SpdyRstStreamFrame) msg; - removeStream(spdyRstStreamFrame.getStreamId(), promise); + removeStream(spdyRstStreamFrame.streamId(), promise); } else if (msg instanceof SpdySettingsFrame) { @@ -616,9 +616,9 @@ public class SpdySessionHandler } else if (msg instanceof SpdyPingFrame) { SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg; - if (isRemoteInitiatedId(spdyPingFrame.getId())) { + if (isRemoteInitiatedId(spdyPingFrame.id())) { ctx.fireExceptionCaught(new IllegalArgumentException( - "invalid PING ID: " + spdyPingFrame.getId())); + "invalid PING ID: " + spdyPingFrame.id())); return; } pings.getAndIncrement(); @@ -633,7 +633,7 @@ public class SpdySessionHandler } else if (msg instanceof SpdyHeadersFrame) { SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg; - int streamId = spdyHeadersFrame.getStreamId(); + int streamId = spdyHeadersFrame.streamId(); // Frames must not be sent on half-closed streams if (spdySession.isLocalSideClosed(streamId)) { @@ -699,7 +699,7 @@ public class SpdySessionHandler */ private boolean isRemoteInitiatedId(int id) { - boolean serverId = SpdyCodecUtil.isServerId(id); + boolean serverId = isServerId(id); return server && !serverId || !server && serverId; } @@ -775,7 +775,7 @@ public class SpdySessionHandler SpdyDataFrame spdyDataFrame = pendingWrite.spdyDataFrame; int dataFrameSize = spdyDataFrame.content().readableBytes(); - int writeStreamId = spdyDataFrame.getStreamId(); + int writeStreamId = spdyDataFrame.streamId(); if (streamId == SPDY_SESSION_STREAM_ID) { newWindowSize = Math.min(newWindowSize, spdySession.getSendWindowSize(writeStreamId)); } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionStatus.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionStatus.java index 577f99f390..caff4b9ecc 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionStatus.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionStatus.java @@ -73,23 +73,39 @@ public class SpdySessionStatus implements Comparable { this.statusPhrase = statusPhrase; } + /** + * @deprecated Use {@link #code()} instead. + */ + @Deprecated + public int getCode() { + return code(); + } + /** * Returns the code of this status. */ - public int getCode() { + public int code() { return code; } + /** + * @deprecated Use {@link #statusPhrase()} instead. + */ + @Deprecated + public String getStatusPhrase() { + return statusPhrase(); + } + /** * Returns the status phrase of this status. */ - public String getStatusPhrase() { + public String statusPhrase() { return statusPhrase; } @Override public int hashCode() { - return getCode(); + return code(); } @Override @@ -98,16 +114,16 @@ public class SpdySessionStatus implements Comparable { return false; } - return getCode() == ((SpdySessionStatus) o).getCode(); + return code() == ((SpdySessionStatus) o).code(); } @Override public String toString() { - return getStatusPhrase(); + return statusPhrase(); } @Override public int compareTo(SpdySessionStatus o) { - return getCode() - o.getCode(); + return code() - o.code(); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySettingsFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySettingsFrame.java index 92aa8cc563..7ec658776e 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySettingsFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySettingsFrame.java @@ -32,11 +32,17 @@ public interface SpdySettingsFrame extends SpdyFrame { int SETTINGS_INITIAL_WINDOW_SIZE = 7; int SETTINGS_CLIENT_CERTIFICATE_VECTOR_SIZE = 8; + /** + * @deprecated Use {@link #ids()} instead. + */ + @Deprecated + Set getIds(); + /** * Returns a {@code Set} of the setting IDs. * The set's iterator will return the IDs in ascending order. */ - Set getIds(); + Set ids(); /** * Returns {@code true} if the setting ID has a value. diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyStreamFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyStreamFrame.java index e5299f9ae9..ca465991b8 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyStreamFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyStreamFrame.java @@ -20,10 +20,16 @@ package io.netty.handler.codec.spdy; */ public interface SpdyStreamFrame extends SpdyFrame { + /** + * @deprecated Use {@link #streamId()} instead. + */ + @Deprecated + int getStreamId(); + /** * Returns the Stream-ID of this frame. */ - int getStreamId(); + int streamId(); /** * Sets the Stream-ID of this frame. The Stream-ID must be positive. diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyStreamStatus.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyStreamStatus.java index ccb0d814d2..912b107a79 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyStreamStatus.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyStreamStatus.java @@ -147,23 +147,39 @@ public class SpdyStreamStatus implements Comparable { this.statusPhrase = statusPhrase; } + /** + * @deprecated Use {@link #code()} instead. + */ + @Deprecated + public int getCode() { + return code(); + } + /** * Returns the code of this status. */ - public int getCode() { + public int code() { return code; } + /** + * @deprecated Use {@link #statusPhrase()} instead. + */ + @Deprecated + public String getStatusPhrase() { + return statusPhrase(); + } + /** * Returns the status phrase of this status. */ - public String getStatusPhrase() { + public String statusPhrase() { return statusPhrase; } @Override public int hashCode() { - return getCode(); + return code(); } @Override @@ -172,16 +188,16 @@ public class SpdyStreamStatus implements Comparable { return false; } - return getCode() == ((SpdyStreamStatus) o).getCode(); + return code() == ((SpdyStreamStatus) o).code(); } @Override public String toString() { - return getStatusPhrase(); + return statusPhrase(); } @Override public int compareTo(SpdyStreamStatus o) { - return getCode() - o.getCode(); + return code() - o.code(); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySynStreamFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySynStreamFrame.java index b4e6331f02..d0c2acf047 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySynStreamFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySynStreamFrame.java @@ -20,21 +20,39 @@ package io.netty.handler.codec.spdy; */ public interface SpdySynStreamFrame extends SpdyHeadersFrame { + /** + * @deprecated Use {@link #associatedStreamId()} instead. + */ + @Deprecated + int getAssociatedToStreamId(); + /** * Returns the Associated-To-Stream-ID of this frame. */ - int getAssociatedToStreamId(); + int associatedStreamId(); + + /** + * @deprecated Use {@link #setAssociatedStreamId(int)} instead. + */ + @Deprecated + SpdySynStreamFrame setAssociatedToStreamId(int associatedToStreamId); /** * Sets the Associated-To-Stream-ID of this frame. * The Associated-To-Stream-ID cannot be negative. */ - SpdySynStreamFrame setAssociatedToStreamId(int associatedToStreamId); + SpdySynStreamFrame setAssociatedStreamId(int associatedStreamId); + + /** + * Use {@link #priority()} instead. + */ + @Deprecated + byte getPriority(); /** * Returns the priority of the stream. */ - byte getPriority(); + byte priority(); /** * Sets the priority of the stream. diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyVersion.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyVersion.java index efea59e331..030ee94ec1 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyVersion.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyVersion.java @@ -21,7 +21,7 @@ public enum SpdyVersion { private final int version; private final int minorVersion; - private SpdyVersion(int version, int minorVersion) { + SpdyVersion(int version, int minorVersion) { this.version = version; this.minorVersion = minorVersion; } diff --git a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyWindowUpdateFrame.java b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyWindowUpdateFrame.java index 587b1f66d2..0ecd308ab0 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyWindowUpdateFrame.java +++ b/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyWindowUpdateFrame.java @@ -20,20 +20,32 @@ package io.netty.handler.codec.spdy; */ public interface SpdyWindowUpdateFrame extends SpdyFrame { + /** + * @deprecated Use {@link #streamId()} instead. + */ + @Deprecated + int getStreamId(); + /** * Returns the Stream-ID of this frame. */ - int getStreamId(); + int streamId(); /** * Sets the Stream-ID of this frame. The Stream-ID cannot be negative. */ SpdyWindowUpdateFrame setStreamId(int streamID); + /** + * @deprecated Use {@link #deltaWindowSize()} instead. + */ + @Deprecated + int getDeltaWindowSize(); + /** * Returns the Delta-Window-Size of this frame. */ - int getDeltaWindowSize(); + int deltaWindowSize(); /** * Sets the Delta-Window-Size of this frame. diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/CookieDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/CookieDecoderTest.java index 4c14954e11..913c7a160a 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/CookieDecoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/CookieDecoderTest.java @@ -15,7 +15,7 @@ */ package io.netty.handler.codec.http; -import static org.junit.Assert.*; +import org.junit.Test; import java.util.Calendar; import java.util.Date; @@ -23,7 +23,7 @@ import java.util.Iterator; import java.util.Set; import java.util.TimeZone; -import org.junit.Test; +import static org.junit.Assert.*; public class CookieDecoderTest { @Test @@ -36,27 +36,27 @@ public class CookieDecoderTest { assertEquals(1, cookies.size()); Cookie cookie = cookies.iterator().next(); assertNotNull(cookie); - assertEquals("myValue", cookie.getValue()); - assertNull(cookie.getComment()); - assertNull(cookie.getCommentUrl()); - assertEquals(".adomainsomewhere", cookie.getDomain()); + assertEquals("myValue", cookie.value()); + assertNull(cookie.comment()); + assertNull(cookie.commentUrl()); + assertEquals(".adomainsomewhere", cookie.domain()); assertFalse(cookie.isDiscard()); boolean fail = true; for (int i = 40; i <= 60; i ++) { - if (cookie.getMaxAge() == i) { + if (cookie.maxAge() == i) { fail = false; break; } } if (fail) { - fail("expected: 50, actual: " + cookie.getMaxAge()); + fail("expected: 50, actual: " + cookie.maxAge()); } - assertEquals("/apathsomewhere", cookie.getPath()); - assertTrue(cookie.getPorts().isEmpty()); + assertEquals("/apathsomewhere", cookie.path()); + assertTrue(cookie.ports().isEmpty()); assertTrue(cookie.isSecure()); - assertEquals(0, cookie.getVersion()); + assertEquals(0, cookie.version()); } @Test @@ -68,16 +68,16 @@ public class CookieDecoderTest { assertEquals(1, cookies.size()); Cookie cookie = cookies.iterator().next(); assertNotNull(cookie); - assertEquals("myValue", cookie.getValue()); - assertNull(cookie.getComment()); - assertNull(cookie.getCommentUrl()); - assertEquals(".adomainsomewhere", cookie.getDomain()); + assertEquals("myValue", cookie.value()); + assertNull(cookie.comment()); + assertNull(cookie.commentUrl()); + assertEquals(".adomainsomewhere", cookie.domain()); assertFalse(cookie.isDiscard()); - assertEquals(50, cookie.getMaxAge()); - assertEquals("/apathsomewhere", cookie.getPath()); - assertTrue(cookie.getPorts().isEmpty()); + assertEquals(50, cookie.maxAge()); + assertEquals("/apathsomewhere", cookie.path()); + assertTrue(cookie.ports().isEmpty()); assertTrue(cookie.isSecure()); - assertEquals(0, cookie.getVersion()); + assertEquals(0, cookie.version()); } @Test public void testDecodingSingleCookieV1() { @@ -86,17 +86,17 @@ public class CookieDecoderTest { Set cookies = CookieDecoder.decode(cookieString); assertEquals(1, cookies.size()); Cookie cookie = cookies.iterator().next(); - assertEquals("myValue", cookie.getValue()); + assertEquals("myValue", cookie.value()); assertNotNull(cookie); - assertEquals("this is a comment", cookie.getComment()); - assertNull(cookie.getCommentUrl()); - assertEquals(".adomainsomewhere", cookie.getDomain()); + assertEquals("this is a comment", cookie.comment()); + assertNull(cookie.commentUrl()); + assertEquals(".adomainsomewhere", cookie.domain()); assertFalse(cookie.isDiscard()); - assertEquals(50, cookie.getMaxAge()); - assertEquals("/apathsomewhere", cookie.getPath()); - assertTrue(cookie.getPorts().isEmpty()); + assertEquals(50, cookie.maxAge()); + assertEquals("/apathsomewhere", cookie.path()); + assertTrue(cookie.ports().isEmpty()); assertTrue(cookie.isSecure()); - assertEquals(1, cookie.getVersion()); + assertEquals(1, cookie.version()); } @Test @@ -108,16 +108,16 @@ public class CookieDecoderTest { assertEquals(1, cookies.size()); Cookie cookie = cookies.iterator().next(); assertNotNull(cookie); - assertEquals("myValue", cookie.getValue()); - assertEquals("this is a comment", cookie.getComment()); - assertNull(cookie.getCommentUrl()); - assertEquals(".adomainsomewhere", cookie.getDomain()); + assertEquals("myValue", cookie.value()); + assertEquals("this is a comment", cookie.comment()); + assertNull(cookie.commentUrl()); + assertEquals(".adomainsomewhere", cookie.domain()); assertFalse(cookie.isDiscard()); - assertEquals(50, cookie.getMaxAge()); - assertEquals("/apathsomewhere", cookie.getPath()); - assertTrue(cookie.getPorts().isEmpty()); + assertEquals(50, cookie.maxAge()); + assertEquals("/apathsomewhere", cookie.path()); + assertTrue(cookie.ports().isEmpty()); assertTrue(cookie.isSecure()); - assertEquals(1, cookie.getVersion()); + assertEquals(1, cookie.version()); } @Test public void testDecodingSingleCookieV2() { @@ -128,18 +128,18 @@ public class CookieDecoderTest { assertEquals(1, cookies.size()); Cookie cookie = cookies.iterator().next(); assertNotNull(cookie); - assertEquals("myValue", cookie.getValue()); - assertEquals("this is a comment", cookie.getComment()); - assertEquals("http://aurl.com", cookie.getCommentUrl()); - assertEquals(".adomainsomewhere", cookie.getDomain()); + assertEquals("myValue", cookie.value()); + assertEquals("this is a comment", cookie.comment()); + assertEquals("http://aurl.com", cookie.commentUrl()); + assertEquals(".adomainsomewhere", cookie.domain()); assertTrue(cookie.isDiscard()); - assertEquals(50, cookie.getMaxAge()); - assertEquals("/apathsomewhere", cookie.getPath()); - assertEquals(2, cookie.getPorts().size()); - assertTrue(cookie.getPorts().contains(80)); - assertTrue(cookie.getPorts().contains(8080)); + assertEquals(50, cookie.maxAge()); + assertEquals("/apathsomewhere", cookie.path()); + assertEquals(2, cookie.ports().size()); + assertTrue(cookie.ports().contains(80)); + assertTrue(cookie.ports().contains(8080)); assertTrue(cookie.isSecure()); - assertEquals(2, cookie.getVersion()); + assertEquals(2, cookie.version()); } @Test @@ -157,42 +157,42 @@ public class CookieDecoderTest { Iterator it = cookies.iterator(); Cookie cookie = it.next(); assertNotNull(cookie); - assertEquals("myValue", cookie.getValue()); - assertEquals("this is a comment", cookie.getComment()); - assertEquals("http://aurl.com", cookie.getCommentUrl()); - assertEquals(".adomainsomewhere", cookie.getDomain()); + assertEquals("myValue", cookie.value()); + assertEquals("this is a comment", cookie.comment()); + assertEquals("http://aurl.com", cookie.commentUrl()); + assertEquals(".adomainsomewhere", cookie.domain()); assertTrue(cookie.isDiscard()); - assertEquals(50, cookie.getMaxAge()); - assertEquals("/apathsomewhere", cookie.getPath()); - assertEquals(2, cookie.getPorts().size()); - assertTrue(cookie.getPorts().contains(80)); - assertTrue(cookie.getPorts().contains(8080)); + assertEquals(50, cookie.maxAge()); + assertEquals("/apathsomewhere", cookie.path()); + assertEquals(2, cookie.ports().size()); + assertTrue(cookie.ports().contains(80)); + assertTrue(cookie.ports().contains(8080)); assertTrue(cookie.isSecure()); - assertEquals(2, cookie.getVersion()); + assertEquals(2, cookie.version()); cookie = it.next(); assertNotNull(cookie); - assertEquals("myValue2", cookie.getValue()); - assertEquals("this is another comment", cookie.getComment()); - assertEquals("http://anotherurl.com", cookie.getCommentUrl()); - assertEquals(".anotherdomainsomewhere", cookie.getDomain()); + assertEquals("myValue2", cookie.value()); + assertEquals("this is another comment", cookie.comment()); + assertEquals("http://anotherurl.com", cookie.commentUrl()); + assertEquals(".anotherdomainsomewhere", cookie.domain()); assertFalse(cookie.isDiscard()); - assertEquals(0, cookie.getMaxAge()); - assertEquals("/anotherpathsomewhere", cookie.getPath()); - assertTrue(cookie.getPorts().isEmpty()); + assertEquals(0, cookie.maxAge()); + assertEquals("/anotherpathsomewhere", cookie.path()); + assertTrue(cookie.ports().isEmpty()); assertFalse(cookie.isSecure()); - assertEquals(2, cookie.getVersion()); + assertEquals(2, cookie.version()); cookie = it.next(); assertNotNull(cookie); - assertEquals("myValue3", cookie.getValue()); - assertNull(cookie.getComment()); - assertNull(cookie.getCommentUrl()); - assertNull(cookie.getDomain()); + assertEquals("myValue3", cookie.value()); + assertNull(cookie.comment()); + assertNull(cookie.commentUrl()); + assertNull(cookie.domain()); assertFalse(cookie.isDiscard()); - assertEquals(0, cookie.getMaxAge()); - assertNull(cookie.getPath()); - assertTrue(cookie.getPorts().isEmpty()); + assertEquals(0, cookie.maxAge()); + assertNull(cookie.path()); + assertTrue(cookie.ports().isEmpty()); assertFalse(cookie.isSecure()); - assertEquals(2, cookie.getVersion()); + assertEquals(2, cookie.version()); } @Test @@ -206,26 +206,26 @@ public class CookieDecoderTest { Cookie c; c = it.next(); - assertEquals(1, c.getVersion()); - assertEquals("Part_Number", c.getName()); - assertEquals("Rocket_Launcher_0001", c.getValue()); - assertEquals("/acme", c.getPath()); - assertNull(c.getComment()); - assertNull(c.getCommentUrl()); - assertNull(c.getDomain()); - assertTrue(c.getPorts().isEmpty()); - assertEquals(Long.MIN_VALUE, c.getMaxAge()); + assertEquals(1, c.version()); + assertEquals("Part_Number", c.name()); + assertEquals("Rocket_Launcher_0001", c.value()); + assertEquals("/acme", c.path()); + assertNull(c.comment()); + assertNull(c.commentUrl()); + assertNull(c.domain()); + assertTrue(c.ports().isEmpty()); + assertEquals(Long.MIN_VALUE, c.maxAge()); c = it.next(); - assertEquals(1, c.getVersion()); - assertEquals("Part_Number", c.getName()); - assertEquals("Riding_Rocket_0023", c.getValue()); - assertEquals("/acme/ammo", c.getPath()); - assertNull(c.getComment()); - assertNull(c.getCommentUrl()); - assertNull(c.getDomain()); - assertTrue(c.getPorts().isEmpty()); - assertEquals(Long.MIN_VALUE, c.getMaxAge()); + assertEquals(1, c.version()); + assertEquals("Part_Number", c.name()); + assertEquals("Riding_Rocket_0023", c.value()); + assertEquals("/acme/ammo", c.path()); + assertNull(c.comment()); + assertNull(c.commentUrl()); + assertNull(c.domain()); + assertTrue(c.ports().isEmpty()); + assertEquals(Long.MIN_VALUE, c.maxAge()); assertFalse(it.hasNext()); } @@ -242,27 +242,27 @@ public class CookieDecoderTest { assertTrue(it.hasNext()); c = it.next(); - assertEquals(1, c.getVersion()); - assertEquals("session_id", c.getName()); - assertEquals("1234", c.getValue()); - assertNull(c.getPath()); - assertNull(c.getComment()); - assertNull(c.getCommentUrl()); - assertNull(c.getDomain()); - assertTrue(c.getPorts().isEmpty()); - assertEquals(Long.MIN_VALUE, c.getMaxAge()); + assertEquals(1, c.version()); + assertEquals("session_id", c.name()); + assertEquals("1234", c.value()); + assertNull(c.path()); + assertNull(c.comment()); + assertNull(c.commentUrl()); + assertNull(c.domain()); + assertTrue(c.ports().isEmpty()); + assertEquals(Long.MIN_VALUE, c.maxAge()); assertTrue(it.hasNext()); c = it.next(); - assertEquals(1, c.getVersion()); - assertEquals("session_id", c.getName()); - assertEquals("1111", c.getValue()); - assertEquals(".cracker.edu", c.getDomain()); - assertNull(c.getPath()); - assertNull(c.getComment()); - assertNull(c.getCommentUrl()); - assertTrue(c.getPorts().isEmpty()); - assertEquals(Long.MIN_VALUE, c.getMaxAge()); + assertEquals(1, c.version()); + assertEquals("session_id", c.name()); + assertEquals("1111", c.value()); + assertEquals(".cracker.edu", c.domain()); + assertNull(c.path()); + assertNull(c.comment()); + assertNull(c.commentUrl()); + assertTrue(c.ports().isEmpty()); + assertEquals(Long.MIN_VALUE, c.maxAge()); assertFalse(it.hasNext()); } @@ -284,36 +284,36 @@ public class CookieDecoderTest { Cookie c; c = it.next(); - assertEquals("a", c.getName()); - assertEquals("", c.getValue()); + assertEquals("a", c.name()); + assertEquals("", c.value()); c = it.next(); - assertEquals("b", c.getName()); - assertEquals("1", c.getValue()); + assertEquals("b", c.name()); + assertEquals("1", c.value()); c = it.next(); - assertEquals("c", c.getName()); - assertEquals("\"1\"2\"", c.getValue()); + assertEquals("c", c.name()); + assertEquals("\"1\"2\"", c.value()); c = it.next(); - assertEquals("d", c.getName()); - assertEquals("1\"2\"3", c.getValue()); + assertEquals("d", c.name()); + assertEquals("1\"2\"3", c.value()); c = it.next(); - assertEquals("e", c.getName()); - assertEquals("\"\"", c.getValue()); + assertEquals("e", c.name()); + assertEquals("\"\"", c.value()); c = it.next(); - assertEquals("f", c.getName()); - assertEquals("1\"\"2", c.getValue()); + assertEquals("f", c.name()); + assertEquals("1\"\"2", c.value()); c = it.next(); - assertEquals("g", c.getName()); - assertEquals("\\", c.getValue()); + assertEquals("g", c.name()); + assertEquals("\\", c.value()); c = it.next(); - assertEquals("h", c.getName()); - assertEquals("';,\\x", c.getValue()); + assertEquals("h", c.name()); + assertEquals("';,\\x", c.value()); assertFalse(it.hasNext()); } @@ -332,30 +332,30 @@ public class CookieDecoderTest { Cookie c; c = it.next(); - assertEquals("__utma", c.getName()); - assertEquals("48461872.1094088325.1258140131.1258140131.1258140131.1", c.getValue()); + assertEquals("__utma", c.name()); + assertEquals("48461872.1094088325.1258140131.1258140131.1258140131.1", c.value()); c = it.next(); - assertEquals("__utmb", c.getName()); - assertEquals("48461872.13.10.1258140131", c.getValue()); + assertEquals("__utmb", c.name()); + assertEquals("48461872.13.10.1258140131", c.value()); c = it.next(); - assertEquals("__utmc", c.getName()); - assertEquals("48461872", c.getValue()); + assertEquals("__utmc", c.name()); + assertEquals("48461872", c.value()); c = it.next(); - assertEquals("__utmz", c.getName()); + assertEquals("__utmz", c.name()); assertEquals("48461872.1258140131.1.1.utmcsr=overstock.com|" + "utmccn=(referral)|utmcmd=referral|utmcct=/Home-Garden/Furniture/Clearance,/clearance,/32/dept.html", - c.getValue()); + c.value()); c = it.next(); - assertEquals("ARPT", c.getName()); - assertEquals("LWUKQPSWRTUN04CKKJI", c.getValue()); + assertEquals("ARPT", c.name()); + assertEquals("LWUKQPSWRTUN04CKKJI", c.value()); c = it.next(); - assertEquals("kw-2E343B92-B097-442c-BFA5-BE371E0325A2", c.getName()); - assertEquals("unfinished furniture", c.getValue()); + assertEquals("kw-2E343B92-B097-442c-BFA5-BE371E0325A2", c.name()); + assertEquals("unfinished furniture", c.value()); assertFalse(it.hasNext()); } @@ -371,7 +371,7 @@ public class CookieDecoderTest { Set cookies = CookieDecoder.decode(source); Cookie c = cookies.iterator().next(); - assertTrue(Math.abs(expectedMaxAge - c.getMaxAge()) < 2); + assertTrue(Math.abs(expectedMaxAge - c.maxAge()) < 2); } @Test @@ -382,7 +382,7 @@ public class CookieDecoderTest { Set cookies = CookieDecoder.decode(source); Cookie c = cookies.iterator().next(); - assertEquals("timeZoneName=(GMT+04:00) Moscow, St. Petersburg, Volgograd&promocode=®ion=BE", c.getValue()); + assertEquals("timeZoneName=(GMT+04:00) Moscow, St. Petersburg, Volgograd&promocode=®ion=BE", c.value()); } @Test @@ -390,9 +390,9 @@ public class CookieDecoderTest { String src = "path=; expires=Mon, 01-Jan-1990 00:00:00 GMT; path=/; domain=.www.google.com"; Set cookies = CookieDecoder.decode(src); Cookie c = cookies.iterator().next(); - assertEquals("path", c.getName()); - assertEquals("", c.getValue()); - assertEquals("/", c.getPath()); + assertEquals("path", c.name()); + assertEquals("", c.value()); + assertEquals("/", c.path()); } @Test @@ -400,8 +400,8 @@ public class CookieDecoderTest { String src = "HTTPOnly="; Set cookies = CookieDecoder.decode(src); Cookie c = cookies.iterator().next(); - assertEquals("HTTPOnly", c.getName()); - assertEquals("", c.getValue()); + assertEquals("HTTPOnly", c.name()); + assertEquals("", c.value()); } @Test @@ -410,11 +410,11 @@ public class CookieDecoderTest { Set cookies = CookieDecoder.decode(src); Iterator i = cookies.iterator(); Cookie c = i.next(); - assertEquals("A", c.getName()); - assertEquals("v=1&lg=en-US,it-IT,it&intl=it&np=1", c.getValue()); + assertEquals("A", c.name()); + assertEquals("v=1&lg=en-US,it-IT,it&intl=it&np=1", c.value()); c = i.next(); - assertEquals("T", c.getName()); - assertEquals("z=E", c.getValue()); + assertEquals("T", c.name()); + assertEquals("z=E", c.value()); } @Test @@ -468,7 +468,7 @@ public class CookieDecoderTest { Set cookies = CookieDecoder.decode("bh=\"" + longValue + "\";"); assertEquals(1, cookies.size()); Cookie c = cookies.iterator().next(); - assertEquals("bh", c.getName()); - assertEquals(longValue, c.getValue()); + assertEquals("bh", c.name()); + assertEquals(longValue, c.value()); } } diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpChunkedInputTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpChunkedInputTest.java index c8fc9d526c..a807bb643e 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpChunkedInputTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpChunkedInputTest.java @@ -99,10 +99,9 @@ public class HttpChunkedInputTest { HttpContent httpContent = (HttpContent) ch.readOutbound(); if (httpContent == null) { break; - } else { - if (lastHttpContent != null) { - assertTrue("Chunk must be DefaultHttpContent", lastHttpContent instanceof DefaultHttpContent); - } + } + if (lastHttpContent != null) { + assertTrue("Chunk must be DefaultHttpContent", lastHttpContent instanceof DefaultHttpContent); } ByteBuf buffer = httpContent.content(); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpInvalidMessageTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpInvalidMessageTest.java index 5b29c8e83e..326add8ad4 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpInvalidMessageTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpInvalidMessageTest.java @@ -35,7 +35,7 @@ public class HttpInvalidMessageTest { EmbeddedChannel ch = new EmbeddedChannel(new HttpRequestDecoder()); ch.writeInbound(Unpooled.copiedBuffer("GET / HTTP/1.0 with extra\r\n", CharsetUtil.UTF_8)); HttpRequest req = (HttpRequest) ch.readInbound(); - DecoderResult dr = req.getDecoderResult(); + DecoderResult dr = req.decoderResult(); assertFalse(dr.isSuccess()); assertTrue(dr.isFailure()); ensureInboundTrafficDiscarded(ch); @@ -49,11 +49,11 @@ public class HttpInvalidMessageTest { ch.writeInbound(Unpooled.copiedBuffer("Bad=Name: Bad Value\r\n", CharsetUtil.UTF_8)); ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.UTF_8)); HttpRequest req = (HttpRequest) ch.readInbound(); - DecoderResult dr = req.getDecoderResult(); + DecoderResult dr = req.decoderResult(); assertFalse(dr.isSuccess()); assertTrue(dr.isFailure()); assertEquals("Good Value", req.headers().get("Good_Name")); - assertEquals("/maybe-something", req.getUri()); + assertEquals("/maybe-something", req.uri()); ensureInboundTrafficDiscarded(ch); } @@ -62,7 +62,7 @@ public class HttpInvalidMessageTest { EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder()); ch.writeInbound(Unpooled.copiedBuffer("HTTP/1.0 BAD_CODE Bad Server\r\n", CharsetUtil.UTF_8)); HttpResponse res = (HttpResponse) ch.readInbound(); - DecoderResult dr = res.getDecoderResult(); + DecoderResult dr = res.decoderResult(); assertFalse(dr.isSuccess()); assertTrue(dr.isFailure()); ensureInboundTrafficDiscarded(ch); @@ -76,10 +76,10 @@ public class HttpInvalidMessageTest { ch.writeInbound(Unpooled.copiedBuffer("Bad=Name: Bad Value\r\n", CharsetUtil.UTF_8)); ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.UTF_8)); HttpResponse res = (HttpResponse) ch.readInbound(); - DecoderResult dr = res.getDecoderResult(); + DecoderResult dr = res.decoderResult(); assertFalse(dr.isSuccess()); assertTrue(dr.isFailure()); - assertEquals("Maybe OK", res.getStatus().reasonPhrase()); + assertEquals("Maybe OK", res.status().reasonPhrase()); assertEquals("Good Value", res.headers().get("Good_Name")); ensureInboundTrafficDiscarded(ch); } @@ -92,10 +92,10 @@ public class HttpInvalidMessageTest { ch.writeInbound(Unpooled.copiedBuffer("BAD_LENGTH\r\n", CharsetUtil.UTF_8)); HttpRequest req = (HttpRequest) ch.readInbound(); - assertTrue(req.getDecoderResult().isSuccess()); + assertTrue(req.decoderResult().isSuccess()); LastHttpContent chunk = (LastHttpContent) ch.readInbound(); - DecoderResult dr = chunk.getDecoderResult(); + DecoderResult dr = chunk.decoderResult(); assertFalse(dr.isSuccess()); assertTrue(dr.isFailure()); ensureInboundTrafficDiscarded(ch); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java index 82efd1f869..10c632cf48 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java @@ -35,8 +35,8 @@ public class HttpResponseDecoderTest { CharsetUtil.US_ASCII)); HttpResponse res = (HttpResponse) ch.readInbound(); - assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.getStatus(), is(HttpResponseStatus.OK)); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.OK)); byte[] data = new byte[64]; for (int i = 0; i < data.length; i++) { @@ -77,8 +77,8 @@ public class HttpResponseDecoderTest { Unpooled.copiedBuffer("HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n", CharsetUtil.US_ASCII)); HttpResponse res = (HttpResponse) ch.readInbound(); - assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.getStatus(), is(HttpResponseStatus.OK)); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.OK)); byte[] data = new byte[64]; for (int i = 0; i < data.length; i++) { @@ -126,8 +126,8 @@ public class HttpResponseDecoderTest { // Read the response headers. HttpResponse res = (HttpResponse) ch.readInbound(); - assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.getStatus(), is(HttpResponseStatus.OK)); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.OK)); assertThat(ch.readInbound(), is(nullValue())); // Close the connection without sending anything. @@ -151,8 +151,8 @@ public class HttpResponseDecoderTest { // Read the response headers. HttpResponse res = (HttpResponse) ch.readInbound(); - assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.getStatus(), is(HttpResponseStatus.OK)); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.OK)); // Read the partial content. HttpContent content = (HttpContent) ch.readInbound(); @@ -182,8 +182,8 @@ public class HttpResponseDecoderTest { // Read the response headers. HttpResponse res = (HttpResponse) ch.readInbound(); - assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.getStatus(), is(HttpResponseStatus.OK)); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.OK)); assertThat(res.headers().get(Names.TRANSFER_ENCODING), is("chunked")); assertThat(ch.readInbound(), is(nullValue())); @@ -203,8 +203,8 @@ public class HttpResponseDecoderTest { // Read the response headers. HttpResponse res = (HttpResponse) ch.readInbound(); - assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.getStatus(), is(HttpResponseStatus.OK)); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.OK)); assertThat(res.headers().get(Names.TRANSFER_ENCODING), is("chunked")); // Read the partial content. @@ -228,8 +228,8 @@ public class HttpResponseDecoderTest { ch.writeInbound(Unpooled.copiedBuffer("HTTP/1.1 200 OK\r\n\r\n", CharsetUtil.US_ASCII)); HttpResponse res = (HttpResponse) ch.readInbound(); - assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.getStatus(), is(HttpResponseStatus.OK)); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.OK)); assertThat(ch.readInbound(), is(nullValue())); assertThat(ch.finish(), is(true)); @@ -247,8 +247,8 @@ public class HttpResponseDecoderTest { ch.writeInbound(Unpooled.copiedBuffer("HTTP/1.1 200 OK\r\n\r\n", CharsetUtil.US_ASCII)); HttpResponse res = (HttpResponse) ch.readInbound(); - assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.getStatus(), is(HttpResponseStatus.OK)); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.OK)); assertThat(ch.readInbound(), is(nullValue())); ch.writeInbound(Unpooled.wrappedBuffer(new byte[1024])); @@ -279,8 +279,8 @@ public class HttpResponseDecoderTest { CharsetUtil.US_ASCII)); HttpResponse res = (HttpResponse) ch.readInbound(); - assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.getStatus(), is(HttpResponseStatus.OK)); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.OK)); LastHttpContent lastContent = (LastHttpContent) ch.readInbound(); assertThat(lastContent.content().isReadable(), is(false)); @@ -329,8 +329,8 @@ public class HttpResponseDecoderTest { ch.writeInbound(Unpooled.wrappedBuffer(content, headerLength, content.length - headerLength)); HttpResponse res = (HttpResponse) ch.readInbound(); - assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.getStatus(), is(HttpResponseStatus.OK)); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.OK)); LastHttpContent lastContent = (LastHttpContent) ch.readInbound(); assertThat(lastContent.content().isReadable(), is(false)); @@ -362,8 +362,8 @@ public class HttpResponseDecoderTest { ch.writeInbound(Unpooled.wrappedBuffer(data, 5, data.length / 2)); HttpResponse res = (HttpResponse) ch.readInbound(); - assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.getStatus(), is(HttpResponseStatus.OK)); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.OK)); HttpContent firstContent = (HttpContent) ch.readInbound(); assertThat(firstContent.content().readableBytes(), is(5)); @@ -410,8 +410,8 @@ public class HttpResponseDecoderTest { ch.writeInbound(Unpooled.wrappedBuffer(data, 5, data.length / 2)); HttpResponse res = (HttpResponse) ch.readInbound(); - assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.getStatus(), is(HttpResponseStatus.OK)); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.OK)); HttpContent firstContent = (HttpContent) ch.readInbound(); assertThat(firstContent.content().readableBytes(), is(5)); @@ -440,8 +440,8 @@ public class HttpResponseDecoderTest { ch.writeInbound(Unpooled.wrappedBuffer(data)); HttpResponse res = (HttpResponse) ch.readInbound(); - assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.getStatus(), is(HttpResponseStatus.SWITCHING_PROTOCOLS)); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.SWITCHING_PROTOCOLS)); HttpContent content = (HttpContent) ch.readInbound(); assertThat(content.content().readableBytes(), is(16)); content.release(); @@ -467,8 +467,8 @@ public class HttpResponseDecoderTest { ch.writeInbound(Unpooled.wrappedBuffer(data, otherData)); HttpResponse res = (HttpResponse) ch.readInbound(); - assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.getStatus(), is(HttpResponseStatus.SWITCHING_PROTOCOLS)); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.status(), is(HttpResponseStatus.SWITCHING_PROTOCOLS)); HttpContent content = (HttpContent) ch.readInbound(); assertThat(content.content().readableBytes(), is(16)); content.release(); @@ -495,10 +495,10 @@ public class HttpResponseDecoderTest { // Garbage input should generate the 999 Unknown response. HttpResponse res = (HttpResponse) ch.readInbound(); - assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_0)); - assertThat(res.getStatus().code(), is(999)); - assertThat(res.getDecoderResult().isFailure(), is(true)); - assertThat(res.getDecoderResult().isFinished(), is(true)); + assertThat(res.protocolVersion(), sameInstance(HttpVersion.HTTP_1_0)); + assertThat(res.status().code(), is(999)); + assertThat(res.decoderResult().isFailure(), is(true)); + assertThat(res.decoderResult().isFinished(), is(true)); assertThat(ch.readInbound(), is(nullValue())); // More garbage should not generate anything (i.e. the decoder discards anything beyond this point.) @@ -527,7 +527,7 @@ public class HttpResponseDecoderTest { // Ensure that the decoder generates the last chunk with correct decoder result. LastHttpContent invalidChunk = (LastHttpContent) channel.readInbound(); - assertThat(invalidChunk.getDecoderResult().isFailure(), is(true)); + assertThat(invalidChunk.decoderResult().isFailure(), is(true)); invalidChunk.release(); // And no more messages should be produced by the decoder. diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/cors/CorsHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/cors/CorsHandlerTest.java index 7381995d3e..135856f783 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/cors/CorsHandlerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/cors/CorsHandlerTest.java @@ -218,14 +218,14 @@ public class CorsHandlerTest { public void simpleRequestShortCurcuit() { final CorsConfig config = CorsConfig.withOrigin("http://localhost:8080").shortCurcuit().build(); final HttpResponse response = simpleRequest(config, "http://localhost:7777"); - assertThat(response.getStatus(), is(FORBIDDEN)); + assertThat(response.status(), is(FORBIDDEN)); } @Test public void simpleRequestNoShortCurcuit() { final CorsConfig config = CorsConfig.withOrigin("http://localhost:8080").build(); final HttpResponse response = simpleRequest(config, "http://localhost:7777"); - assertThat(response.getStatus(), is(OK)); + assertThat(response.status(), is(OK)); assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_ORIGIN), is(nullValue())); } @@ -233,7 +233,7 @@ public class CorsHandlerTest { public void shortCurcuitNonCorsRequest() { final CorsConfig config = CorsConfig.withOrigin("https://localhost").shortCurcuit().build(); final HttpResponse response = simpleRequest(config, null); - assertThat(response.getStatus(), is(OK)); + assertThat(response.status(), is(OK)); assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_ORIGIN), is(nullValue())); } @@ -269,7 +269,7 @@ public class CorsHandlerTest { final EmbeddedChannel channel = new EmbeddedChannel(new CorsHandler(config)); final FullHttpRequest httpRequest = createHttpRequest(OPTIONS); httpRequest.headers().set(ORIGIN, origin); - httpRequest.headers().set(ACCESS_CONTROL_REQUEST_METHOD, httpRequest.getMethod().toString()); + httpRequest.headers().set(ACCESS_CONTROL_REQUEST_METHOD, httpRequest.method().toString()); httpRequest.headers().set(ACCESS_CONTROL_REQUEST_HEADERS, requestHeaders); channel.writeInbound(httpRequest); return (HttpResponse) channel.readOutbound(); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java index bf89cf539e..98952caf4b 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java @@ -54,7 +54,7 @@ public class WebSocketServerProtocolHandlerTest { EmbeddedChannel ch = createChannel(new MockOutboundHandler()); ChannelHandlerContext handshakerCtx = ch.pipeline().context(WebSocketServerProtocolHandshakeHandler.class); writeUpgradeRequest(ch); - assertEquals(SWITCHING_PROTOCOLS, ReferenceCountUtil.releaseLater(responses.remove()).getStatus()); + assertEquals(SWITCHING_PROTOCOLS, ReferenceCountUtil.releaseLater(responses.remove()).status()); assertNotNull(WebSocketServerProtocolHandler.getHandshaker(handshakerCtx)); } @@ -63,10 +63,10 @@ public class WebSocketServerProtocolHandlerTest { EmbeddedChannel ch = createChannel(); writeUpgradeRequest(ch); - assertEquals(SWITCHING_PROTOCOLS, ReferenceCountUtil.releaseLater(responses.remove()).getStatus()); + assertEquals(SWITCHING_PROTOCOLS, ReferenceCountUtil.releaseLater(responses.remove()).status()); ch.writeInbound(new DefaultFullHttpRequest(HTTP_1_1, HttpMethod.GET, "/test")); - assertEquals(FORBIDDEN, ReferenceCountUtil.releaseLater(responses.remove()).getStatus()); + assertEquals(FORBIDDEN, ReferenceCountUtil.releaseLater(responses.remove()).status()); } @Test @@ -83,7 +83,7 @@ public class WebSocketServerProtocolHandlerTest { ch.writeInbound(httpRequestWithEntity); FullHttpResponse response = ReferenceCountUtil.releaseLater(responses.remove()); - assertEquals(BAD_REQUEST, response.getStatus()); + assertEquals(BAD_REQUEST, response.status()); assertEquals("not a WebSocket handshake request: missing upgrade", getResponseMessage(response)); } @@ -102,7 +102,7 @@ public class WebSocketServerProtocolHandlerTest { ch.writeInbound(httpRequest); FullHttpResponse response = ReferenceCountUtil.releaseLater(responses.remove()); - assertEquals(BAD_REQUEST, response.getStatus()); + assertEquals(BAD_REQUEST, response.status()); assertEquals("not a WebSocket request: missing key", getResponseMessage(response)); } diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java index 52aa5d7bc6..5c42ae362f 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java @@ -371,7 +371,7 @@ public class SpdyFrameDecoderTest { encodeControlFrameHeader(buf, type, flags, length); buf.writeInt(streamId | 0x80000000); // should ignore reserved bit buf.writeInt(associatedToStreamId | 0x80000000); // should ignore reserved bit - buf.writeByte((priority << 5) | 0x1F); // should ignore reserved bits + buf.writeByte(priority << 5 | 0x1F); // should ignore reserved bits buf.writeByte(0xFF); // should ignore reserved bits delegate.readSynStreamFrame(streamId, associatedToStreamId, priority, false, false); diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java index 0988375514..a27075666d 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdySessionHandlerTest.java @@ -43,7 +43,7 @@ public class SpdySessionHandlerTest { assertNotNull(msg); assertTrue(msg instanceof SpdyDataFrame); SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg; - assertEquals(streamId, spdyDataFrame.getStreamId()); + assertEquals(streamId, spdyDataFrame.streamId()); assertEquals(last, spdyDataFrame.isLast()); } @@ -57,29 +57,29 @@ public class SpdySessionHandlerTest { assertNotNull(msg); assertTrue(msg instanceof SpdyRstStreamFrame); SpdyRstStreamFrame spdyRstStreamFrame = (SpdyRstStreamFrame) msg; - assertEquals(streamId, spdyRstStreamFrame.getStreamId()); - assertEquals(status, spdyRstStreamFrame.getStatus()); + assertEquals(streamId, spdyRstStreamFrame.streamId()); + assertEquals(status, spdyRstStreamFrame.status()); } private static void assertPing(Object msg, int id) { assertNotNull(msg); assertTrue(msg instanceof SpdyPingFrame); SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg; - assertEquals(id, spdyPingFrame.getId()); + assertEquals(id, spdyPingFrame.id()); } private static void assertGoAway(Object msg, int lastGoodStreamId) { assertNotNull(msg); assertTrue(msg instanceof SpdyGoAwayFrame); SpdyGoAwayFrame spdyGoAwayFrame = (SpdyGoAwayFrame) msg; - assertEquals(lastGoodStreamId, spdyGoAwayFrame.getLastGoodStreamId()); + assertEquals(lastGoodStreamId, spdyGoAwayFrame.lastGoodStreamId()); } private static void assertHeaders(Object msg, int streamId, boolean last, SpdyHeaders headers) { assertNotNull(msg); assertTrue(msg instanceof SpdyHeadersFrame); SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg; - assertEquals(streamId, spdyHeadersFrame.getStreamId()); + assertEquals(streamId, spdyHeadersFrame.streamId()); assertEquals(last, spdyHeadersFrame.isLast()); for (String name: headers.names()) { List expectedValues = headers.getAll(name); @@ -158,7 +158,7 @@ public class SpdySessionHandlerTest { assertNull(sessionHandler.readOutbound()); // Check if session handler rejects HEADERS for closed streams - int testStreamId = spdyDataFrame.getStreamId(); + int testStreamId = spdyDataFrame.streamId(); sessionHandler.writeInbound(spdyDataFrame); assertDataFrame(sessionHandler.readOutbound(), testStreamId, spdyDataFrame.isLast()); assertNull(sessionHandler.readOutbound()); @@ -223,7 +223,7 @@ public class SpdySessionHandlerTest { // Check if session handler returns identical local PINGs sessionHandler.writeInbound(localPingFrame); - assertPing(sessionHandler.readOutbound(), localPingFrame.getId()); + assertPing(sessionHandler.readOutbound(), localPingFrame.id()); assertNull(sessionHandler.readOutbound()); // Check if session handler ignores un-initiated remote PINGs @@ -335,11 +335,11 @@ public class SpdySessionHandlerTest { new DefaultSpdySynStreamFrame(streamId, 0, (byte) 0); spdySynStreamFrame.setLast(true); ctx.writeAndFlush(spdySynStreamFrame); - spdySynStreamFrame.setStreamId(spdySynStreamFrame.getStreamId() + 2); + spdySynStreamFrame.setStreamId(spdySynStreamFrame.streamId() + 2); ctx.writeAndFlush(spdySynStreamFrame); - spdySynStreamFrame.setStreamId(spdySynStreamFrame.getStreamId() + 2); + spdySynStreamFrame.setStreamId(spdySynStreamFrame.streamId() + 2); ctx.writeAndFlush(spdySynStreamFrame); - spdySynStreamFrame.setStreamId(spdySynStreamFrame.getStreamId() + 2); + spdySynStreamFrame.setStreamId(spdySynStreamFrame.streamId() + 2); ctx.writeAndFlush(spdySynStreamFrame); // Limit the number of concurrent streams to 1 @@ -354,7 +354,7 @@ public class SpdySessionHandlerTest { SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg; if (!spdySynStreamFrame.isUnidirectional()) { - int streamId = spdySynStreamFrame.getStreamId(); + int streamId = spdySynStreamFrame.streamId(); SpdySynReplyFrame spdySynReplyFrame = new DefaultSpdySynReplyFrame(streamId); spdySynReplyFrame.setLast(spdySynStreamFrame.isLast()); for (Map.Entry entry: spdySynStreamFrame.headers()) { diff --git a/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java b/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java index b31798c4a2..ea74522125 100644 --- a/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java +++ b/example/src/main/java/io/netty/example/http/file/HttpStaticFileServerHandler.java @@ -117,12 +117,12 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler buf.append("WELCOME TO THE WILD WILD WEB SERVER\r\n"); buf.append("===================================\r\n"); - buf.append("VERSION: ").append(request.getProtocolVersion()).append("\r\n"); + buf.append("VERSION: ").append(request.protocolVersion()).append("\r\n"); buf.append("HOSTNAME: ").append(getHost(request, "unknown")).append("\r\n"); - buf.append("REQUEST_URI: ").append(request.getUri()).append("\r\n\r\n"); + buf.append("REQUEST_URI: ").append(request.uri()).append("\r\n\r\n"); HttpHeaders headers = request.headers(); if (!headers.isEmpty()) { @@ -82,7 +82,7 @@ public class HttpSnoopServerHandler extends SimpleChannelInboundHandler buf.append("\r\n"); } - QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.getUri()); + QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.uri()); Map> params = queryStringDecoder.parameters(); if (!params.isEmpty()) { for (Entry> p: params.entrySet()) { diff --git a/example/src/main/java/io/netty/example/http/upload/HttpUploadClientHandler.java b/example/src/main/java/io/netty/example/http/upload/HttpUploadClientHandler.java index a0c4545601..dfcff09ead 100644 --- a/example/src/main/java/io/netty/example/http/upload/HttpUploadClientHandler.java +++ b/example/src/main/java/io/netty/example/http/upload/HttpUploadClientHandler.java @@ -36,8 +36,8 @@ public class HttpUploadClientHandler extends SimpleChannelInboundHandler> uriAttributes = decoderQuery.parameters(); for (Entry> attr: uriAttributes.entrySet()) { for (String attrVal: attr.getValue()) { @@ -139,7 +140,14 @@ public class HttpUploadServerHandler extends SimpleChannelInboundHandler if (msg instanceof FullHttpResponse) { FullHttpResponse response = (FullHttpResponse) msg; throw new IllegalStateException( - "Unexpected FullHttpResponse (getStatus=" + response.getStatus() + + "Unexpected FullHttpResponse (getStatus=" + response.status() + ", content=" + response.content().toString(CharsetUtil.UTF_8) + ')'); } diff --git a/example/src/main/java/io/netty/example/http/websocketx/server/WebSocketServerHandler.java b/example/src/main/java/io/netty/example/http/websocketx/server/WebSocketServerHandler.java index e19a0b7820..f2cd2546d1 100644 --- a/example/src/main/java/io/netty/example/http/websocketx/server/WebSocketServerHandler.java +++ b/example/src/main/java/io/netty/example/http/websocketx/server/WebSocketServerHandler.java @@ -70,13 +70,13 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler } // Allow only GET methods. - if (req.getMethod() != GET) { + if (req.method() != GET) { sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN)); return; } // Send the demo page and favicon.ico - if ("/".equals(req.getUri())) { + if ("/".equals(req.uri())) { ByteBuf content = WebSocketServerIndexPage.getContent(getWebSocketLocation(req)); FullHttpResponse res = new DefaultFullHttpResponse(HTTP_1_1, OK, content); @@ -86,7 +86,7 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler sendHttpResponse(ctx, req, res); return; } - if ("/favicon.ico".equals(req.getUri())) { + if ("/favicon.ico".equals(req.uri())) { FullHttpResponse res = new DefaultFullHttpResponse(HTTP_1_1, NOT_FOUND); sendHttpResponse(ctx, req, res); return; @@ -128,8 +128,8 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler private static void sendHttpResponse( ChannelHandlerContext ctx, FullHttpRequest req, FullHttpResponse res) { // Generate an error page if response getStatus code is not OK (200). - if (res.getStatus().code() != 200) { - ByteBuf buf = Unpooled.copiedBuffer(res.getStatus().toString(), CharsetUtil.UTF_8); + if (res.status().code() != 200) { + ByteBuf buf = Unpooled.copiedBuffer(res.status().toString(), CharsetUtil.UTF_8); res.content().writeBytes(buf); buf.release(); setContentLength(res, res.content().readableBytes()); @@ -137,7 +137,7 @@ public class WebSocketServerHandler extends SimpleChannelInboundHandler // Send the response and close the connection if necessary. ChannelFuture f = ctx.channel().writeAndFlush(res); - if (!isKeepAlive(req) || res.getStatus().code() != 200) { + if (!isKeepAlive(req) || res.status().code() != 200) { f.addListener(ChannelFutureListener.CLOSE); } } diff --git a/example/src/main/java/io/netty/example/spdy/client/HttpResponseClientHandler.java b/example/src/main/java/io/netty/example/spdy/client/HttpResponseClientHandler.java index d06a50123f..a6e3da284f 100644 --- a/example/src/main/java/io/netty/example/spdy/client/HttpResponseClientHandler.java +++ b/example/src/main/java/io/netty/example/spdy/client/HttpResponseClientHandler.java @@ -42,8 +42,8 @@ public class HttpResponseClientHandler extends SimpleChannelInboundHandler