From 2bdcedeffd9aca6651db422c2f7b587ca3190f51 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 27 Jun 2014 16:40:43 +0900 Subject: [PATCH] Partially revert 4a13f66e131c3eb3d4293c198be0a613644d3a9c Revert the removal of 'get' prefix from HTTP classes to ensure ABI compatibility. Note that this commit does not revert the changes in SPDY, which is considered experimental. --- .../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 | 2 +- .../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/ServerCookieEncoder.java | 40 +-- .../handler/codec/http/cors/CorsHandler.java | 6 +- .../multipart/HttpPostRequestEncoder.java | 31 +- .../WebSocketClientHandshaker00.java | 4 +- .../WebSocketClientHandshaker07.java | 4 +- .../WebSocketClientHandshaker08.java | 4 +- .../WebSocketClientHandshaker13.java | 4 +- ...bSocketServerProtocolHandshakeHandler.java | 4 +- .../codec/rtsp/RtspRequestEncoder.java | 6 +- .../codec/rtsp/RtspResponseEncoder.java | 6 +- .../handler/codec/spdy/SpdyHttpEncoder.java | 14 +- .../handler/codec/http/CookieDecoderTest.java | 292 +++++++++--------- .../codec/http/HttpInvalidMessageTest.java | 16 +- .../codec/http/HttpResponseDecoderTest.java | 66 ++-- .../codec/http/cors/CorsHandlerTest.java | 8 +- .../WebSocketServerProtocolHandlerTest.java | 10 +- .../file/HttpStaticFileServerHandler.java | 4 +- .../http/snoop/HttpSnoopClientHandler.java | 4 +- .../http/snoop/HttpSnoopServerHandler.java | 6 +- .../http/upload/HttpUploadClientHandler.java | 6 +- .../http/upload/HttpUploadServerHandler.java | 12 +- .../client/WebSocketClientHandler.java | 2 +- .../server/WebSocketServerHandler.java | 12 +- .../client/HttpResponseClientHandler.java | 4 +- .../autobahn/AutobahnServerHandler.java | 8 +- 49 files changed, 369 insertions(+), 569 deletions(-) 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 308e890f1a..5a5b5bae74 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.version() >= 1) { + if (c.getVersion() >= 1) { add(buf, '$' + CookieHeaderNames.VERSION, 1); } - add(buf, c.name(), c.value()); + add(buf, c.getName(), c.getValue()); - if (c.path() != null) { - add(buf, '$' + CookieHeaderNames.PATH, c.path()); + if (c.getPath() != null) { + add(buf, '$' + CookieHeaderNames.PATH, c.getPath()); } - if (c.domain() != null) { - add(buf, '$' + CookieHeaderNames.DOMAIN, c.domain()); + if (c.getDomain() != null) { + add(buf, '$' + CookieHeaderNames.DOMAIN, c.getDomain()); } - if (c.version() >= 1) { - if (!c.ports().isEmpty()) { + if (c.getVersion() >= 1) { + if (!c.getPorts().isEmpty()) { buf.append('$'); buf.append(CookieHeaderNames.PORT); buf.append((char) HttpConstants.EQUALS); buf.append((char) HttpConstants.DOUBLE_QUOTE); - for (int port: c.ports()) { + for (int port: c.getPorts()) { 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 9195b28273..be9278bd47 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,14 +60,8 @@ final class ComposedLastHttpContent implements LastHttpContent { } @Override - public DecoderResult decoderResult() { - return result; - } - - @Override - @Deprecated public DecoderResult getDecoderResult() { - return decoderResult(); + return result; } @Override 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 45e47d6791..c154d2de26 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,31 +23,19 @@ 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 name(); - - /** - * @deprecated Use {@link #value()} instead. - */ - @Deprecated - String getValue(); + String getName(); /** * Returns the value of this {@link Cookie}. * * @return The value of this {@link Cookie} */ - String value(); + String getValue(); /** * Sets the value of this {@link Cookie}. @@ -56,18 +44,12 @@ 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 domain(); + String getDomain(); /** * Sets the domain of this {@link Cookie}. @@ -76,18 +58,12 @@ 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 path(); + String getPath(); /** * Sets the path of this {@link Cookie}. @@ -96,18 +72,12 @@ 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 comment(); + String getComment(); /** * Sets the comment of this {@link Cookie}. @@ -116,18 +86,12 @@ 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 maxAge(); + long getMaxAge(); /** * Sets the maximum age of this {@link Cookie} in seconds. @@ -140,18 +104,12 @@ 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 version(); + int getVersion(); /** * Sets the version of this {@link Cookie}. @@ -195,18 +153,12 @@ 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 commentUrl(); + String getCommentUrl(); /** * Sets the comment URL of this {@link Cookie}. @@ -232,18 +184,12 @@ 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 ports(); + Set getPorts(); /** * 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 66b421c607..7e6512196c 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,24 +78,12 @@ 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; } @@ -108,13 +96,7 @@ public class DefaultCookie implements Cookie { } @Override - @Deprecated public String getDomain() { - return domain(); - } - - @Override - public String domain() { return domain; } @@ -124,13 +106,7 @@ public class DefaultCookie implements Cookie { } @Override - @Deprecated public String getPath() { - return path(); - } - - @Override - public String path() { return path; } @@ -140,13 +116,7 @@ public class DefaultCookie implements Cookie { } @Override - @Deprecated public String getComment() { - return comment(); - } - - @Override - public String comment() { return comment; } @@ -156,13 +126,7 @@ public class DefaultCookie implements Cookie { } @Override - @Deprecated public String getCommentUrl() { - return commentUrl(); - } - - @Override - public String commentUrl() { return commentUrl; } @@ -182,13 +146,7 @@ public class DefaultCookie implements Cookie { } @Override - @Deprecated public Set getPorts() { - return ports(); - } - - @Override - public Set ports() { if (unmodifiablePorts == null) { unmodifiablePorts = Collections.unmodifiableSet(ports); } @@ -235,13 +193,7 @@ public class DefaultCookie implements Cookie { } @Override - @Deprecated public long getMaxAge() { - return maxAge(); - } - - @Override - public long maxAge() { return maxAge; } @@ -251,13 +203,7 @@ public class DefaultCookie implements Cookie { } @Override - @Deprecated public int getVersion() { - return version(); - } - - @Override - public int version() { return version; } @@ -288,7 +234,7 @@ public class DefaultCookie implements Cookie { @Override public int hashCode() { - return name().hashCode(); + return getName().hashCode(); } @Override @@ -298,28 +244,28 @@ public class DefaultCookie implements Cookie { } Cookie that = (Cookie) o; - if (!name().equalsIgnoreCase(that.name())) { + if (!getName().equalsIgnoreCase(that.getName())) { return false; } - if (path() == null) { - if (that.path() != null) { + if (getPath() == null) { + if (that.getPath() != null) { return false; } - } else if (that.path() == null) { + } else if (that.getPath() == null) { return false; - } else if (!path().equals(that.path())) { + } else if (!getPath().equals(that.getPath())) { return false; } - if (domain() == null) { - if (that.domain() != null) { + if (getDomain() == null) { + if (that.getDomain() != null) { return false; } - } else if (that.domain() == null) { + } else if (that.getDomain() == null) { return false; } else { - return domain().equalsIgnoreCase(that.domain()); + return getDomain().equalsIgnoreCase(that.getDomain()); } return true; @@ -328,32 +274,32 @@ public class DefaultCookie implements Cookie { @Override public int compareTo(Cookie c) { int v; - v = name().compareToIgnoreCase(c.name()); + v = getName().compareToIgnoreCase(c.getName()); if (v != 0) { return v; } - if (path() == null) { - if (c.path() != null) { + if (getPath() == null) { + if (c.getPath() != null) { return -1; } - } else if (c.path() == null) { + } else if (c.getPath() == null) { return 1; } else { - v = path().compareTo(c.path()); + v = getPath().compareTo(c.getPath()); if (v != 0) { return v; } } - if (domain() == null) { - if (c.domain() != null) { + if (getDomain() == null) { + if (c.getDomain() != null) { return -1; } - } else if (c.domain() == null) { + } else if (c.getDomain() == null) { return 1; } else { - v = domain().compareToIgnoreCase(c.domain()); + v = getDomain().compareToIgnoreCase(c.getDomain()); return v; } @@ -363,24 +309,24 @@ public class DefaultCookie implements Cookie { @Override public String toString() { StringBuilder buf = new StringBuilder(); - buf.append(name()); + buf.append(getName()); buf.append('='); - buf.append(value()); - if (domain() != null) { + buf.append(getValue()); + if (getDomain() != null) { buf.append(", domain="); - buf.append(domain()); + buf.append(getDomain()); } - if (path() != null) { + if (getPath() != null) { buf.append(", path="); - buf.append(path()); + buf.append(getPath()); } - if (comment() != null) { + if (getComment() != null) { buf.append(", comment="); - buf.append(comment()); + buf.append(getComment()); } - if (maxAge() >= 0) { + if (getMaxAge() >= 0) { buf.append(", maxAge="); - buf.append(maxAge()); + buf.append(getMaxAge()); 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 d9f6430ee9..8ea1983ef3 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( - protocolVersion(), method(), uri(), content().copy(), validateHeaders); + getProtocolVersion(), getMethod(), getUri(), 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( - protocolVersion(), method(), uri(), content().duplicate(), validateHeaders); + getProtocolVersion(), getMethod(), getUri(), 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 d5982b1de8..77d19e594c 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( - protocolVersion(), status(), content().copy(), validateHeaders); + getProtocolVersion(), getStatus(), 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(protocolVersion(), status(), + DefaultFullHttpResponse duplicate = new DefaultFullHttpResponse(getProtocolVersion(), getStatus(), 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 5a599015ab..162ac5803d 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() + ", decoderResult: " + decoderResult() + ')'; + "(data: " + content() + ", decoderResult: " + getDecoderResult() + ')'; } } 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 be1483fd3b..b6e0889414 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,13 +48,7 @@ public abstract class DefaultHttpMessage extends DefaultHttpObject implements Ht } @Override - @Deprecated public HttpVersion getProtocolVersion() { - return protocolVersion(); - } - - @Override - public HttpVersion protocolVersion() { return version; } @@ -63,7 +57,7 @@ public abstract class DefaultHttpMessage extends DefaultHttpObject implements Ht StringBuilder buf = new StringBuilder(); buf.append(StringUtil.simpleClassName(this)); buf.append("(version: "); - buf.append(protocolVersion().text()); + buf.append(getProtocolVersion().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 d08ad72b94..11f3c23c55 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,12 +26,6 @@ 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 0eabb97c3b..22d3231d0e 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,24 +57,12 @@ 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; } @@ -107,14 +95,14 @@ public class DefaultHttpRequest extends DefaultHttpMessage implements HttpReques StringBuilder buf = new StringBuilder(); buf.append(StringUtil.simpleClassName(this)); buf.append("(decodeResult: "); - buf.append(decoderResult()); + buf.append(getDecoderResult()); buf.append(')'); buf.append(StringUtil.NEWLINE); - buf.append(method()); + buf.append(getMethod()); buf.append(' '); - buf.append(uri()); + buf.append(getUri()); buf.append(' '); - buf.append(protocolVersion().text()); + buf.append(getProtocolVersion().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 40f3469a2d..d93443a8c7 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,13 +50,7 @@ public class DefaultHttpResponse extends DefaultHttpMessage implements HttpRespo } @Override - @Deprecated public HttpResponseStatus getStatus() { - return status(); - } - - @Override - public HttpResponseStatus status() { return status; } @@ -80,12 +74,12 @@ public class DefaultHttpResponse extends DefaultHttpMessage implements HttpRespo StringBuilder buf = new StringBuilder(); buf.append(StringUtil.simpleClassName(this)); buf.append("(decodeResult: "); - buf.append(decoderResult()); + buf.append(getDecoderResult()); buf.append(')'); buf.append(StringUtil.NEWLINE); - buf.append(protocolVersion().text()); + buf.append(getProtocolVersion().text()); buf.append(' '); - buf.append(status()); + buf.append(getStatus()); 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 4c40836bca..e7a7610a9d 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).method()); + queue.offer(((HttpRequest) msg).getMethod()); } super.encode(ctx, msg, out); @@ -156,7 +156,7 @@ public final class HttpClientCodec @Override protected boolean isContentAlwaysEmpty(HttpMessage msg) { - final int statusCode = ((HttpResponse) msg).status().code(); + final int statusCode = ((HttpResponse) msg).getStatus().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 d2f22fc118..e4660d3896 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).status().code() == 100) { + if (msg instanceof HttpResponse && ((HttpResponse) msg).getStatus().code() == 100) { if (!(msg instanceof LastHttpContent)) { continueResponse = true; diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java index 6ec143b9ca..0b54d4d88f 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentEncoder.java @@ -89,7 +89,7 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec> return false; } - if (message.protocolVersion().isKeepAliveDefault()) { + if (message.getProtocolVersion().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.protocolVersion().isKeepAliveDefault()) { + if (message.getProtocolVersion().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.method()) && + if (HttpMethod.GET.equals(req.getMethod()) && 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.status().code() == 101 && + if (res.getStatus().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.protocolVersion().compareTo(HttpVersion.HTTP_1_1) < 0) { + if (message.getProtocolVersion().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 357ad99bca..7faabd2f60 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 @@ -26,16 +26,12 @@ package io.netty.handler.codec.http; */ public interface HttpMessage extends HttpObject { - /** - * @deprecated Use {@link #protocolVersion()} instead. - */ - @Deprecated - HttpVersion getProtocolVersion(); - /** * Returns the protocol version of this {@link HttpMessage} + * + * @return The protocol version */ - HttpVersion protocolVersion(); + HttpVersion getProtocolVersion(); /** * 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 2bdc379a5f..f28a785cb8 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,17 +18,10 @@ 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 decoderResult(); + DecoderResult getDecoderResult(); /** * 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 d2d1384227..43d87dabc0 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.decoderResult().isSuccess()) { + if (!m.getDecoderResult().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.protocolVersion(), - header.method(), header.uri(), Unpooled.compositeBuffer(maxCumulationBufferComponents)); + this.currentMessage = currentMessage = new DefaultFullHttpRequest(header.getProtocolVersion(), + header.getMethod(), header.getUri(), Unpooled.compositeBuffer(maxCumulationBufferComponents)); } else if (msg instanceof HttpResponse) { HttpResponse header = (HttpResponse) msg; this.currentMessage = currentMessage = new DefaultFullHttpResponse( - header.protocolVersion(), header.status(), + header.getProtocolVersion(), header.getStatus(), Unpooled.compositeBuffer(maxCumulationBufferComponents)); } else { throw new Error(); @@ -193,9 +193,9 @@ public class HttpObjectAggregator extends MessageToMessageDecoder { } final boolean last; - if (!chunk.decoderResult().isSuccess()) { + if (!chunk.getDecoderResult().isSuccess()) { currentMessage.setDecoderResult( - DecoderResult.failure(chunk.decoderResult().cause())); + DecoderResult.failure(chunk.getDecoderResult().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.protocolVersion(), req.method(), req.uri(), Unpooled.EMPTY_BUFFER, false); + req.getProtocolVersion(), req.getMethod(), req.getUri(), Unpooled.EMPTY_BUFFER, false); } else if (msg instanceof HttpResponse) { HttpResponse res = (HttpResponse) msg; fullMsg = new DefaultFullHttpResponse( - res.protocolVersion(), res.status(), Unpooled.EMPTY_BUFFER, false); + res.getProtocolVersion(), res.getStatus(), 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 ada45bdc41..05b915fbbd 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.method().encode(buf); + request.getMethod().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.uri(); + String uri = request.getUri(); 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.protocolVersion().encode(buf); + request.getProtocolVersion().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 44cb77e361..7c7ebe2427 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,18 +31,12 @@ 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 status(); + HttpResponseStatus getStatus(); /** * 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 5a4c7c5cc3..07e2414998 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.protocolVersion().encode(buf); + response.getProtocolVersion().encode(buf); buf.writeByte(SP); - response.status().encode(buf); + response.getStatus().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 518e31fe22..d93d1d1865 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,12 +50,6 @@ 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/ServerCookieEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/ServerCookieEncoder.java index 3c71ddcc66..b49a033a53 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.name(), cookie.value()); + add(buf, cookie.getName(), cookie.getValue()); - if (cookie.maxAge() != Long.MIN_VALUE) { - if (cookie.version() == 0) { + if (cookie.getMaxAge() != Long.MIN_VALUE) { + if (cookie.getVersion() == 0) { addUnquoted(buf, CookieHeaderNames.EXPIRES, HttpHeaderDateFormat.get().format( new Date(System.currentTimeMillis() + - cookie.maxAge() * 1000L))); + cookie.getMaxAge() * 1000L))); } else { - add(buf, CookieHeaderNames.MAX_AGE, cookie.maxAge()); + add(buf, CookieHeaderNames.MAX_AGE, cookie.getMaxAge()); } } - if (cookie.path() != null) { - if (cookie.version() > 0) { - add(buf, CookieHeaderNames.PATH, cookie.path()); + if (cookie.getPath() != null) { + if (cookie.getVersion() > 0) { + add(buf, CookieHeaderNames.PATH, cookie.getPath()); } else { - addUnquoted(buf, CookieHeaderNames.PATH, cookie.path()); + addUnquoted(buf, CookieHeaderNames.PATH, cookie.getPath()); } } - if (cookie.domain() != null) { - if (cookie.version() > 0) { - add(buf, CookieHeaderNames.DOMAIN, cookie.domain()); + if (cookie.getDomain() != null) { + if (cookie.getVersion() > 0) { + add(buf, CookieHeaderNames.DOMAIN, cookie.getDomain()); } else { - addUnquoted(buf, CookieHeaderNames.DOMAIN, cookie.domain()); + addUnquoted(buf, CookieHeaderNames.DOMAIN, cookie.getDomain()); } } if (cookie.isSecure()) { @@ -87,22 +87,22 @@ public final class ServerCookieEncoder { buf.append((char) HttpConstants.SEMICOLON); buf.append((char) HttpConstants.SP); } - if (cookie.version() >= 1) { - if (cookie.comment() != null) { - add(buf, CookieHeaderNames.COMMENT, cookie.comment()); + if (cookie.getVersion() >= 1) { + if (cookie.getComment() != null) { + add(buf, CookieHeaderNames.COMMENT, cookie.getComment()); } add(buf, CookieHeaderNames.VERSION, 1); - if (cookie.commentUrl() != null) { - addQuoted(buf, CookieHeaderNames.COMMENTURL, cookie.commentUrl()); + if (cookie.getCommentUrl() != null) { + addQuoted(buf, CookieHeaderNames.COMMENTURL, cookie.getCommentUrl()); } - if (!cookie.ports().isEmpty()) { + if (!cookie.getPorts().isEmpty()) { buf.append(CookieHeaderNames.PORT); buf.append((char) HttpConstants.EQUALS); buf.append((char) HttpConstants.DOUBLE_QUOTE); - for (int port: cookie.ports()) { + for (int port: cookie.getPorts()) { 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 dea12c83ce..fa16ac0859 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.protocolVersion(), OK); + final HttpResponse response = new DefaultFullHttpResponse(request.getProtocolVersion(), 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.method().equals(OPTIONS) && + return request.getMethod().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.protocolVersion(), FORBIDDEN)) + ctx.writeAndFlush(new DefaultFullHttpResponse(request.getProtocolVersion(), FORBIDDEN)) .addListener(ChannelFutureListener.CLOSE); } } 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 b4ba99ff59..4765485348 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.method() != HttpMethod.POST) { + if (request.getMethod() != HttpMethod.POST) { throw new ErrorDataEncoderException("Cannot create a Encoder if not a POST"); } this.request = request; @@ -1116,32 +1116,17 @@ public class HttpPostRequestEncoder implements ChunkedInput { @Override public HttpMethod getMethod() { - return request.method(); - } - - @Override - public HttpMethod method() { - return request.method(); + return request.getMethod(); } @Override public String getUri() { - return request.uri(); - } - - @Override - public String uri() { - return request.uri(); + return request.getUri(); } @Override public HttpVersion getProtocolVersion() { - return request.protocolVersion(); - } - - @Override - public HttpVersion protocolVersion() { - return request.protocolVersion(); + return request.getProtocolVersion(); } @Override @@ -1150,14 +1135,8 @@ public class HttpPostRequestEncoder implements ChunkedInput { } @Override - public DecoderResult decoderResult() { - return request.decoderResult(); - } - - @Override - @Deprecated public DecoderResult getDecoderResult() { - return request.decoderResult(); + return request.getDecoderResult(); } @Override diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java index 2f8e4a52fb..4ec7833e66 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker00.java @@ -191,8 +191,8 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker { protected void verify(FullHttpResponse response) { final HttpResponseStatus status = new HttpResponseStatus(101, "WebSocket Protocol Handshake"); - if (!response.status().equals(status)) { - throw new WebSocketHandshakeException("Invalid handshake response getStatus: " + response.status()); + if (!response.getStatus().equals(status)) { + throw new WebSocketHandshakeException("Invalid handshake response getStatus: " + response.getStatus()); } HttpHeaders headers = response.headers(); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker07.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker07.java index ff9bafcada..6db3d4c501 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker07.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker07.java @@ -168,8 +168,8 @@ public class WebSocketClientHandshaker07 extends WebSocketClientHandshaker { final HttpResponseStatus status = HttpResponseStatus.SWITCHING_PROTOCOLS; final HttpHeaders headers = response.headers(); - if (!response.status().equals(status)) { - throw new WebSocketHandshakeException("Invalid handshake response getStatus: " + response.status()); + if (!response.getStatus().equals(status)) { + throw new WebSocketHandshakeException("Invalid handshake response getStatus: " + response.getStatus()); } String upgrade = headers.get(Names.UPGRADE); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java index f0e8cc30ed..d2eee599cb 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker08.java @@ -168,8 +168,8 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker { final HttpResponseStatus status = HttpResponseStatus.SWITCHING_PROTOCOLS; final HttpHeaders headers = response.headers(); - if (!response.status().equals(status)) { - throw new WebSocketHandshakeException("Invalid handshake response getStatus: " + response.status()); + if (!response.getStatus().equals(status)) { + throw new WebSocketHandshakeException("Invalid handshake response getStatus: " + response.getStatus()); } String upgrade = headers.get(Names.UPGRADE); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java index ae9cb19b4a..a3d9b9c272 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshaker13.java @@ -178,8 +178,8 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker { final HttpResponseStatus status = HttpResponseStatus.SWITCHING_PROTOCOLS; final HttpHeaders headers = response.headers(); - if (!response.status().equals(status)) { - throw new WebSocketHandshakeException("Invalid handshake response getStatus: " + response.status()); + if (!response.getStatus().equals(status)) { + throw new WebSocketHandshakeException("Invalid handshake response getStatus: " + response.getStatus()); } String upgrade = headers.get(Names.UPGRADE); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java index 920fb2a5ba..3dc011056c 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandshakeHandler.java @@ -55,7 +55,7 @@ class WebSocketServerProtocolHandshakeHandler public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exception { FullHttpRequest req = (FullHttpRequest) msg; try { - if (req.method() != GET) { + if (req.getMethod() != GET) { sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN)); return; } @@ -90,7 +90,7 @@ class WebSocketServerProtocolHandshakeHandler private static void sendHttpResponse(ChannelHandlerContext ctx, HttpRequest req, HttpResponse res) { ChannelFuture f = ctx.channel().writeAndFlush(res); - if (!isKeepAlive(req) || res.status().code() != 200) { + if (!isKeepAlive(req) || res.getStatus().code() != 200) { f.addListener(ChannelFutureListener.CLOSE); } } diff --git a/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspRequestEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspRequestEncoder.java index 4ce121dde4..c1ae1c206d 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspRequestEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/rtsp/RtspRequestEncoder.java @@ -38,11 +38,11 @@ public class RtspRequestEncoder extends RtspObjectEncoder { @Override protected void encodeInitialLine(ByteBuf buf, HttpRequest request) throws Exception { - encodeAscii(request.method().toString(), buf); + encodeAscii(request.getMethod().toString(), buf); buf.writeByte(SP); - buf.writeBytes(request.uri().getBytes(CharsetUtil.UTF_8)); + buf.writeBytes(request.getUri().getBytes(CharsetUtil.UTF_8)); buf.writeByte(SP); - encodeAscii(request.protocolVersion().toString(), buf); + encodeAscii(request.getProtocolVersion().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 33d71c5e6c..3474901267 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.protocolVersion().toString(), buf); + encodeAscii(response.getProtocolVersion().toString(), buf); buf.writeByte(SP); - buf.writeBytes(String.valueOf(response.status().code()).getBytes(CharsetUtil.US_ASCII)); + buf.writeBytes(String.valueOf(response.getStatus().code()).getBytes(CharsetUtil.US_ASCII)); buf.writeByte(SP); - encodeAscii(String.valueOf(response.status().reasonPhrase()), buf); + encodeAscii(String.valueOf(response.getStatus().reasonPhrase()), buf); buf.writeBytes(CRLF); } } 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 23d5aea282..d392ce56fb 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.method()); - SpdyHeaders.setUrl(spdyVersion, spdySynStreamFrame, httpRequest.uri()); - SpdyHeaders.setVersion(spdyVersion, spdySynStreamFrame, httpMessage.protocolVersion()); + SpdyHeaders.setMethod(spdyVersion, spdySynStreamFrame, httpRequest.getMethod()); + SpdyHeaders.setUrl(spdyVersion, spdySynStreamFrame, httpRequest.getUri()); + SpdyHeaders.setVersion(spdyVersion, spdySynStreamFrame, httpMessage.getProtocolVersion()); } if (httpMessage instanceof HttpResponse) { HttpResponse httpResponse = (HttpResponse) httpMessage; - SpdyHeaders.setStatus(spdyVersion, spdySynStreamFrame, httpResponse.status()); + SpdyHeaders.setStatus(spdyVersion, spdySynStreamFrame, httpResponse.getStatus()); SpdyHeaders.setUrl(spdyVersion, spdySynStreamFrame, URL); - SpdyHeaders.setVersion(spdyVersion, spdySynStreamFrame, httpMessage.protocolVersion()); + SpdyHeaders.setVersion(spdyVersion, spdySynStreamFrame, httpMessage.getProtocolVersion()); spdySynStreamFrame.setUnidirectional(true); } @@ -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.status()); - SpdyHeaders.setVersion(spdyVersion, spdySynReplyFrame, httpResponse.protocolVersion()); + SpdyHeaders.setStatus(spdyVersion, spdySynReplyFrame, httpResponse.getStatus()); + SpdyHeaders.setVersion(spdyVersion, spdySynReplyFrame, httpResponse.getProtocolVersion()); // Transfer the remaining HTTP headers for (Map.Entry entry: httpResponse.headers()) { 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 913c7a160a..bdf546c730 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 @@ -36,27 +36,27 @@ public class CookieDecoderTest { assertEquals(1, cookies.size()); Cookie cookie = cookies.iterator().next(); assertNotNull(cookie); - assertEquals("myValue", cookie.value()); - assertNull(cookie.comment()); - assertNull(cookie.commentUrl()); - assertEquals(".adomainsomewhere", cookie.domain()); + assertEquals("myValue", cookie.getValue()); + assertNull(cookie.getComment()); + assertNull(cookie.getCommentUrl()); + assertEquals(".adomainsomewhere", cookie.getDomain()); assertFalse(cookie.isDiscard()); boolean fail = true; for (int i = 40; i <= 60; i ++) { - if (cookie.maxAge() == i) { + if (cookie.getMaxAge() == i) { fail = false; break; } } if (fail) { - fail("expected: 50, actual: " + cookie.maxAge()); + fail("expected: 50, actual: " + cookie.getMaxAge()); } - assertEquals("/apathsomewhere", cookie.path()); - assertTrue(cookie.ports().isEmpty()); + assertEquals("/apathsomewhere", cookie.getPath()); + assertTrue(cookie.getPorts().isEmpty()); assertTrue(cookie.isSecure()); - assertEquals(0, cookie.version()); + assertEquals(0, cookie.getVersion()); } @Test @@ -68,16 +68,16 @@ public class CookieDecoderTest { assertEquals(1, cookies.size()); Cookie cookie = cookies.iterator().next(); assertNotNull(cookie); - assertEquals("myValue", cookie.value()); - assertNull(cookie.comment()); - assertNull(cookie.commentUrl()); - assertEquals(".adomainsomewhere", cookie.domain()); + assertEquals("myValue", cookie.getValue()); + assertNull(cookie.getComment()); + assertNull(cookie.getCommentUrl()); + assertEquals(".adomainsomewhere", cookie.getDomain()); assertFalse(cookie.isDiscard()); - assertEquals(50, cookie.maxAge()); - assertEquals("/apathsomewhere", cookie.path()); - assertTrue(cookie.ports().isEmpty()); + assertEquals(50, cookie.getMaxAge()); + assertEquals("/apathsomewhere", cookie.getPath()); + assertTrue(cookie.getPorts().isEmpty()); assertTrue(cookie.isSecure()); - assertEquals(0, cookie.version()); + assertEquals(0, cookie.getVersion()); } @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.value()); + assertEquals("myValue", cookie.getValue()); assertNotNull(cookie); - assertEquals("this is a comment", cookie.comment()); - assertNull(cookie.commentUrl()); - assertEquals(".adomainsomewhere", cookie.domain()); + assertEquals("this is a comment", cookie.getComment()); + assertNull(cookie.getCommentUrl()); + assertEquals(".adomainsomewhere", cookie.getDomain()); assertFalse(cookie.isDiscard()); - assertEquals(50, cookie.maxAge()); - assertEquals("/apathsomewhere", cookie.path()); - assertTrue(cookie.ports().isEmpty()); + assertEquals(50, cookie.getMaxAge()); + assertEquals("/apathsomewhere", cookie.getPath()); + assertTrue(cookie.getPorts().isEmpty()); assertTrue(cookie.isSecure()); - assertEquals(1, cookie.version()); + assertEquals(1, cookie.getVersion()); } @Test @@ -108,16 +108,16 @@ public class CookieDecoderTest { assertEquals(1, cookies.size()); Cookie cookie = cookies.iterator().next(); assertNotNull(cookie); - assertEquals("myValue", cookie.value()); - assertEquals("this is a comment", cookie.comment()); - assertNull(cookie.commentUrl()); - assertEquals(".adomainsomewhere", cookie.domain()); + assertEquals("myValue", cookie.getValue()); + assertEquals("this is a comment", cookie.getComment()); + assertNull(cookie.getCommentUrl()); + assertEquals(".adomainsomewhere", cookie.getDomain()); assertFalse(cookie.isDiscard()); - assertEquals(50, cookie.maxAge()); - assertEquals("/apathsomewhere", cookie.path()); - assertTrue(cookie.ports().isEmpty()); + assertEquals(50, cookie.getMaxAge()); + assertEquals("/apathsomewhere", cookie.getPath()); + assertTrue(cookie.getPorts().isEmpty()); assertTrue(cookie.isSecure()); - assertEquals(1, cookie.version()); + assertEquals(1, cookie.getVersion()); } @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.value()); - assertEquals("this is a comment", cookie.comment()); - assertEquals("http://aurl.com", cookie.commentUrl()); - assertEquals(".adomainsomewhere", cookie.domain()); + assertEquals("myValue", cookie.getValue()); + assertEquals("this is a comment", cookie.getComment()); + assertEquals("http://aurl.com", cookie.getCommentUrl()); + assertEquals(".adomainsomewhere", cookie.getDomain()); assertTrue(cookie.isDiscard()); - assertEquals(50, cookie.maxAge()); - assertEquals("/apathsomewhere", cookie.path()); - assertEquals(2, cookie.ports().size()); - assertTrue(cookie.ports().contains(80)); - assertTrue(cookie.ports().contains(8080)); + assertEquals(50, cookie.getMaxAge()); + assertEquals("/apathsomewhere", cookie.getPath()); + assertEquals(2, cookie.getPorts().size()); + assertTrue(cookie.getPorts().contains(80)); + assertTrue(cookie.getPorts().contains(8080)); assertTrue(cookie.isSecure()); - assertEquals(2, cookie.version()); + assertEquals(2, cookie.getVersion()); } @Test @@ -157,42 +157,42 @@ public class CookieDecoderTest { Iterator it = cookies.iterator(); Cookie cookie = it.next(); assertNotNull(cookie); - assertEquals("myValue", cookie.value()); - assertEquals("this is a comment", cookie.comment()); - assertEquals("http://aurl.com", cookie.commentUrl()); - assertEquals(".adomainsomewhere", cookie.domain()); + assertEquals("myValue", cookie.getValue()); + assertEquals("this is a comment", cookie.getComment()); + assertEquals("http://aurl.com", cookie.getCommentUrl()); + assertEquals(".adomainsomewhere", cookie.getDomain()); assertTrue(cookie.isDiscard()); - assertEquals(50, cookie.maxAge()); - assertEquals("/apathsomewhere", cookie.path()); - assertEquals(2, cookie.ports().size()); - assertTrue(cookie.ports().contains(80)); - assertTrue(cookie.ports().contains(8080)); + assertEquals(50, cookie.getMaxAge()); + assertEquals("/apathsomewhere", cookie.getPath()); + assertEquals(2, cookie.getPorts().size()); + assertTrue(cookie.getPorts().contains(80)); + assertTrue(cookie.getPorts().contains(8080)); assertTrue(cookie.isSecure()); - assertEquals(2, cookie.version()); + assertEquals(2, cookie.getVersion()); cookie = it.next(); assertNotNull(cookie); - assertEquals("myValue2", cookie.value()); - assertEquals("this is another comment", cookie.comment()); - assertEquals("http://anotherurl.com", cookie.commentUrl()); - assertEquals(".anotherdomainsomewhere", cookie.domain()); + assertEquals("myValue2", cookie.getValue()); + assertEquals("this is another comment", cookie.getComment()); + assertEquals("http://anotherurl.com", cookie.getCommentUrl()); + assertEquals(".anotherdomainsomewhere", cookie.getDomain()); assertFalse(cookie.isDiscard()); - assertEquals(0, cookie.maxAge()); - assertEquals("/anotherpathsomewhere", cookie.path()); - assertTrue(cookie.ports().isEmpty()); + assertEquals(0, cookie.getMaxAge()); + assertEquals("/anotherpathsomewhere", cookie.getPath()); + assertTrue(cookie.getPorts().isEmpty()); assertFalse(cookie.isSecure()); - assertEquals(2, cookie.version()); + assertEquals(2, cookie.getVersion()); cookie = it.next(); assertNotNull(cookie); - assertEquals("myValue3", cookie.value()); - assertNull(cookie.comment()); - assertNull(cookie.commentUrl()); - assertNull(cookie.domain()); + assertEquals("myValue3", cookie.getValue()); + assertNull(cookie.getComment()); + assertNull(cookie.getCommentUrl()); + assertNull(cookie.getDomain()); assertFalse(cookie.isDiscard()); - assertEquals(0, cookie.maxAge()); - assertNull(cookie.path()); - assertTrue(cookie.ports().isEmpty()); + assertEquals(0, cookie.getMaxAge()); + assertNull(cookie.getPath()); + assertTrue(cookie.getPorts().isEmpty()); assertFalse(cookie.isSecure()); - assertEquals(2, cookie.version()); + assertEquals(2, cookie.getVersion()); } @Test @@ -206,26 +206,26 @@ public class CookieDecoderTest { Cookie c; c = it.next(); - 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()); + 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()); c = it.next(); - 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()); + 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()); assertFalse(it.hasNext()); } @@ -242,27 +242,27 @@ public class CookieDecoderTest { assertTrue(it.hasNext()); c = it.next(); - 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()); + 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()); assertTrue(it.hasNext()); c = it.next(); - 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()); + 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()); assertFalse(it.hasNext()); } @@ -284,36 +284,36 @@ public class CookieDecoderTest { Cookie c; c = it.next(); - assertEquals("a", c.name()); - assertEquals("", c.value()); + assertEquals("a", c.getName()); + assertEquals("", c.getValue()); c = it.next(); - assertEquals("b", c.name()); - assertEquals("1", c.value()); + assertEquals("b", c.getName()); + assertEquals("1", c.getValue()); c = it.next(); - assertEquals("c", c.name()); - assertEquals("\"1\"2\"", c.value()); + assertEquals("c", c.getName()); + assertEquals("\"1\"2\"", c.getValue()); c = it.next(); - assertEquals("d", c.name()); - assertEquals("1\"2\"3", c.value()); + assertEquals("d", c.getName()); + assertEquals("1\"2\"3", c.getValue()); c = it.next(); - assertEquals("e", c.name()); - assertEquals("\"\"", c.value()); + assertEquals("e", c.getName()); + assertEquals("\"\"", c.getValue()); c = it.next(); - assertEquals("f", c.name()); - assertEquals("1\"\"2", c.value()); + assertEquals("f", c.getName()); + assertEquals("1\"\"2", c.getValue()); c = it.next(); - assertEquals("g", c.name()); - assertEquals("\\", c.value()); + assertEquals("g", c.getName()); + assertEquals("\\", c.getValue()); c = it.next(); - assertEquals("h", c.name()); - assertEquals("';,\\x", c.value()); + assertEquals("h", c.getName()); + assertEquals("';,\\x", c.getValue()); assertFalse(it.hasNext()); } @@ -332,30 +332,30 @@ public class CookieDecoderTest { Cookie c; c = it.next(); - assertEquals("__utma", c.name()); - assertEquals("48461872.1094088325.1258140131.1258140131.1258140131.1", c.value()); + assertEquals("__utma", c.getName()); + assertEquals("48461872.1094088325.1258140131.1258140131.1258140131.1", c.getValue()); c = it.next(); - assertEquals("__utmb", c.name()); - assertEquals("48461872.13.10.1258140131", c.value()); + assertEquals("__utmb", c.getName()); + assertEquals("48461872.13.10.1258140131", c.getValue()); c = it.next(); - assertEquals("__utmc", c.name()); - assertEquals("48461872", c.value()); + assertEquals("__utmc", c.getName()); + assertEquals("48461872", c.getValue()); c = it.next(); - assertEquals("__utmz", c.name()); + assertEquals("__utmz", c.getName()); assertEquals("48461872.1258140131.1.1.utmcsr=overstock.com|" + "utmccn=(referral)|utmcmd=referral|utmcct=/Home-Garden/Furniture/Clearance,/clearance,/32/dept.html", - c.value()); + c.getValue()); c = it.next(); - assertEquals("ARPT", c.name()); - assertEquals("LWUKQPSWRTUN04CKKJI", c.value()); + assertEquals("ARPT", c.getName()); + assertEquals("LWUKQPSWRTUN04CKKJI", c.getValue()); c = it.next(); - assertEquals("kw-2E343B92-B097-442c-BFA5-BE371E0325A2", c.name()); - assertEquals("unfinished furniture", c.value()); + assertEquals("kw-2E343B92-B097-442c-BFA5-BE371E0325A2", c.getName()); + assertEquals("unfinished furniture", c.getValue()); 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.maxAge()) < 2); + assertTrue(Math.abs(expectedMaxAge - c.getMaxAge()) < 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.value()); + assertEquals("timeZoneName=(GMT+04:00) Moscow, St. Petersburg, Volgograd&promocode=®ion=BE", c.getValue()); } @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.name()); - assertEquals("", c.value()); - assertEquals("/", c.path()); + assertEquals("path", c.getName()); + assertEquals("", c.getValue()); + assertEquals("/", c.getPath()); } @Test @@ -400,8 +400,8 @@ public class CookieDecoderTest { String src = "HTTPOnly="; Set cookies = CookieDecoder.decode(src); Cookie c = cookies.iterator().next(); - assertEquals("HTTPOnly", c.name()); - assertEquals("", c.value()); + assertEquals("HTTPOnly", c.getName()); + assertEquals("", c.getValue()); } @Test @@ -410,11 +410,11 @@ public class CookieDecoderTest { Set cookies = CookieDecoder.decode(src); Iterator i = cookies.iterator(); Cookie c = i.next(); - assertEquals("A", c.name()); - assertEquals("v=1&lg=en-US,it-IT,it&intl=it&np=1", c.value()); + assertEquals("A", c.getName()); + assertEquals("v=1&lg=en-US,it-IT,it&intl=it&np=1", c.getValue()); c = i.next(); - assertEquals("T", c.name()); - assertEquals("z=E", c.value()); + assertEquals("T", c.getName()); + assertEquals("z=E", c.getValue()); } @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.name()); - assertEquals(longValue, c.value()); + assertEquals("bh", c.getName()); + assertEquals(longValue, c.getValue()); } } 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 326add8ad4..5b29c8e83e 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.decoderResult(); + DecoderResult dr = req.getDecoderResult(); 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.decoderResult(); + DecoderResult dr = req.getDecoderResult(); assertFalse(dr.isSuccess()); assertTrue(dr.isFailure()); assertEquals("Good Value", req.headers().get("Good_Name")); - assertEquals("/maybe-something", req.uri()); + assertEquals("/maybe-something", req.getUri()); 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.decoderResult(); + DecoderResult dr = res.getDecoderResult(); 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.decoderResult(); + DecoderResult dr = res.getDecoderResult(); assertFalse(dr.isSuccess()); assertTrue(dr.isFailure()); - assertEquals("Maybe OK", res.status().reasonPhrase()); + assertEquals("Maybe OK", res.getStatus().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.decoderResult().isSuccess()); + assertTrue(req.getDecoderResult().isSuccess()); LastHttpContent chunk = (LastHttpContent) ch.readInbound(); - DecoderResult dr = chunk.decoderResult(); + DecoderResult dr = chunk.getDecoderResult(); 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 10c632cf48..82efd1f869 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.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.status(), is(HttpResponseStatus.OK)); + assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.getStatus(), 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.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.status(), is(HttpResponseStatus.OK)); + assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.getStatus(), 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.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.status(), is(HttpResponseStatus.OK)); + assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.getStatus(), 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.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.status(), is(HttpResponseStatus.OK)); + assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.getStatus(), 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.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.status(), is(HttpResponseStatus.OK)); + assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.getStatus(), 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.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.status(), is(HttpResponseStatus.OK)); + assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.getStatus(), 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.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.status(), is(HttpResponseStatus.OK)); + assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.getStatus(), 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.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.status(), is(HttpResponseStatus.OK)); + assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.getStatus(), 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.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.status(), is(HttpResponseStatus.OK)); + assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.getStatus(), 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.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.status(), is(HttpResponseStatus.OK)); + assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.getStatus(), 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.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.status(), is(HttpResponseStatus.OK)); + assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.getStatus(), 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.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.status(), is(HttpResponseStatus.OK)); + assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.getStatus(), 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.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.status(), is(HttpResponseStatus.SWITCHING_PROTOCOLS)); + assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.getStatus(), 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.protocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); - assertThat(res.status(), is(HttpResponseStatus.SWITCHING_PROTOCOLS)); + assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); + assertThat(res.getStatus(), 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.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(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(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.decoderResult().isFailure(), is(true)); + assertThat(invalidChunk.getDecoderResult().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 135856f783..7381995d3e 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.status(), is(FORBIDDEN)); + assertThat(response.getStatus(), 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.status(), is(OK)); + assertThat(response.getStatus(), 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.status(), is(OK)); + assertThat(response.getStatus(), 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.method().toString()); + httpRequest.headers().set(ACCESS_CONTROL_REQUEST_METHOD, httpRequest.getMethod().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 98952caf4b..bf89cf539e 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()).status()); + assertEquals(SWITCHING_PROTOCOLS, ReferenceCountUtil.releaseLater(responses.remove()).getStatus()); assertNotNull(WebSocketServerProtocolHandler.getHandshaker(handshakerCtx)); } @@ -63,10 +63,10 @@ public class WebSocketServerProtocolHandlerTest { EmbeddedChannel ch = createChannel(); writeUpgradeRequest(ch); - assertEquals(SWITCHING_PROTOCOLS, ReferenceCountUtil.releaseLater(responses.remove()).status()); + assertEquals(SWITCHING_PROTOCOLS, ReferenceCountUtil.releaseLater(responses.remove()).getStatus()); ch.writeInbound(new DefaultFullHttpRequest(HTTP_1_1, HttpMethod.GET, "/test")); - assertEquals(FORBIDDEN, ReferenceCountUtil.releaseLater(responses.remove()).status()); + assertEquals(FORBIDDEN, ReferenceCountUtil.releaseLater(responses.remove()).getStatus()); } @Test @@ -83,7 +83,7 @@ public class WebSocketServerProtocolHandlerTest { ch.writeInbound(httpRequestWithEntity); FullHttpResponse response = ReferenceCountUtil.releaseLater(responses.remove()); - assertEquals(BAD_REQUEST, response.status()); + assertEquals(BAD_REQUEST, response.getStatus()); 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.status()); + assertEquals(BAD_REQUEST, response.getStatus()); assertEquals("not a WebSocket request: missing key", getResponseMessage(response)); } 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 ea74522125..b31798c4a2 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.protocolVersion()).append("\r\n"); + buf.append("VERSION: ").append(request.getProtocolVersion()).append("\r\n"); buf.append("HOSTNAME: ").append(getHost(request, "unknown")).append("\r\n"); - buf.append("REQUEST_URI: ").append(request.uri()).append("\r\n\r\n"); + buf.append("REQUEST_URI: ").append(request.getUri()).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.uri()); + QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.getUri()); 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 dfcff09ead..a0c4545601 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()) { @@ -140,7 +140,7 @@ public class HttpUploadServerHandler extends SimpleChannelInboundHandler if (msg instanceof FullHttpResponse) { FullHttpResponse response = (FullHttpResponse) msg; throw new IllegalStateException( - "Unexpected FullHttpResponse (getStatus=" + response.status() + + "Unexpected FullHttpResponse (getStatus=" + response.getStatus() + ", 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 f2cd2546d1..e19a0b7820 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.method() != GET) { + if (req.getMethod() != GET) { sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN)); return; } // Send the demo page and favicon.ico - if ("/".equals(req.uri())) { + if ("/".equals(req.getUri())) { 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.uri())) { + if ("/favicon.ico".equals(req.getUri())) { 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.status().code() != 200) { - ByteBuf buf = Unpooled.copiedBuffer(res.status().toString(), CharsetUtil.UTF_8); + if (res.getStatus().code() != 200) { + ByteBuf buf = Unpooled.copiedBuffer(res.getStatus().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.status().code() != 200) { + if (!isKeepAlive(req) || res.getStatus().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 a6e3da284f..d06a50123f 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