Add setters and getters back to Http Objects

* This is done because we noticed that the previous change limit the usage more then it gave us any benefit. Now it is possible
  again to rewrite the url on the fly or reuse the objects when writing a proxy and so limit the GC pressure.
* Fixes also #979
This commit is contained in:
Norman Maurer 2013-01-30 07:42:18 +01:00
parent c5ccaee506
commit 238e03f75b
68 changed files with 373 additions and 264 deletions

View File

@ -126,7 +126,7 @@ public interface Cookie extends Comparable<Cookie> {
boolean isSecure();
/**
* Sets the security status of this {@link Cookie}
* Sets the security getStatus of this {@link Cookie}
*
* @param secure True if this {@link Cookie} is to be secure, otherwise false
*/

View File

@ -57,9 +57,28 @@ public class DefaultFullHttpRequest extends DefaultHttpRequest implements FullHt
content.free();
}
@Override
public FullHttpRequest setProtocolVersion(HttpVersion version) {
super.setProtocolVersion(version);
return this;
}
@Override
public FullHttpRequest setMethod(HttpMethod method) {
super.setMethod(method);
return this;
}
@Override
public FullHttpRequest setUri(String uri) {
super.setUri(uri);
return this;
}
@Override
public FullHttpRequest copy() {
DefaultFullHttpRequest copy = new DefaultFullHttpRequest(protocolVersion(), method(), uri(), data().copy());
DefaultFullHttpRequest copy = new DefaultFullHttpRequest(
getProtocolVersion(), getMethod(), getUri(), data().copy());
copy.headers().set(headers());
copy.trailingHeaders().set(trailingHeaders());
return copy;

View File

@ -59,9 +59,21 @@ public class DefaultFullHttpResponse extends DefaultHttpResponse implements Full
content.free();
}
@Override
public FullHttpResponse setProtocolVersion(HttpVersion version) {
super.setProtocolVersion(version);
return this;
}
@Override
public FullHttpResponse setStatus(HttpResponseStatus status) {
super.setStatus(status);
return this;
}
@Override
public FullHttpResponse copy() {
DefaultFullHttpResponse copy = new DefaultFullHttpResponse(protocolVersion(), status(), data().copy());
DefaultFullHttpResponse copy = new DefaultFullHttpResponse(getProtocolVersion(), getStatus(), data().copy());
copy.headers().set(headers());
copy.trailingHeaders().set(trailingHeaders());
return copy;

View File

@ -56,6 +56,6 @@ public class DefaultHttpContent extends DefaultHttpObject implements HttpContent
@Override
public String toString() {
return getClass().getSimpleName() + "(data: " + data() + ", decoderResult: " + decoderResult() + ')';
return getClass().getSimpleName() + "(data: " + data() + ", getDecoderResult: " + getDecoderResult() + ')';
}
}

View File

@ -24,7 +24,7 @@ import java.util.Map;
*/
public abstract class DefaultHttpMessage extends DefaultHttpObject implements HttpMessage {
private final HttpVersion version;
private HttpVersion version;
private final HttpHeaders headers = new DefaultHttpHeaders();
/**
@ -43,7 +43,7 @@ public abstract class DefaultHttpMessage extends DefaultHttpObject implements Ht
}
@Override
public HttpVersion protocolVersion() {
public HttpVersion getProtocolVersion() {
return version;
}
@ -52,7 +52,7 @@ public abstract class DefaultHttpMessage extends DefaultHttpObject implements Ht
StringBuilder buf = new StringBuilder();
buf.append(getClass().getSimpleName());
buf.append("(version: ");
buf.append(protocolVersion().text());
buf.append(getProtocolVersion().text());
buf.append(", keepAlive: ");
buf.append(HttpHeaders.isKeepAlive(this));
buf.append(')');
@ -64,6 +64,12 @@ public abstract class DefaultHttpMessage extends DefaultHttpObject implements Ht
return buf.toString();
}
@Override
public HttpMessage setProtocolVersion(HttpVersion version) {
this.version = version;
return this;
}
void appendHeaders(StringBuilder buf) {
for (Map.Entry<String, String> e: headers()) {
buf.append(e.getKey());

View File

@ -26,12 +26,12 @@ public class DefaultHttpObject implements HttpObject {
}
@Override
public DecoderResult decoderResult() {
public DecoderResult getDecoderResult() {
return decoderResult;
}
@Override
public void updateDecoderResult(DecoderResult decoderResult) {
public void setDecoderResult(DecoderResult decoderResult) {
if (decoderResult == null) {
throw new NullPointerException("decoderResult");
}

View File

@ -22,51 +22,69 @@ import io.netty.util.internal.StringUtil;
*/
public class DefaultHttpRequest extends DefaultHttpMessage implements HttpRequest {
private final HttpMethod method;
private final String uri;
private HttpMethod method;
private String uri;
/**
* Creates a new instance.
*
* @param httpVersion the HTTP version of the request
* @param method the HTTP method of the request
* @param method the HTTP getMethod of the request
* @param uri the URI or path of the request
*/
public DefaultHttpRequest(HttpVersion httpVersion, HttpMethod method, String uri) {
super(httpVersion);
if (method == null) {
throw new NullPointerException("method");
throw new NullPointerException("getMethod");
}
if (uri == null) {
throw new NullPointerException("uri");
throw new NullPointerException("getUri");
}
this.method = method;
this.uri = uri;
}
@Override
public HttpMethod method() {
public HttpMethod getMethod() {
return method;
}
@Override
public String uri() {
public String getUri() {
return uri;
}
@Override
public HttpRequest setMethod(HttpMethod method) {
this.method = method;
return this;
}
@Override
public HttpRequest setUri(String uri) {
this.uri = uri;
return this;
}
@Override
public HttpRequest setProtocolVersion(HttpVersion version) {
super.setProtocolVersion(version);
return this;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append(getClass().getSimpleName());
buf.append(", decodeResult: ");
buf.append(decoderResult());
buf.append(getDecoderResult());
buf.append(')');
buf.append(StringUtil.NEWLINE);
buf.append(method().toString());
buf.append(getMethod().toString());
buf.append(' ');
buf.append(uri());
buf.append(getUri());
buf.append(' ');
buf.append(protocolVersion().text());
buf.append(getProtocolVersion().text());
buf.append(StringUtil.NEWLINE);
appendHeaders(buf);

View File

@ -22,13 +22,13 @@ import io.netty.util.internal.StringUtil;
*/
public class DefaultHttpResponse extends DefaultHttpMessage implements HttpResponse {
private final HttpResponseStatus status;
private HttpResponseStatus status;
/**
* Creates a new instance.
*
* @param version the HTTP version of this response
* @param status the status of this response
* @param status the getStatus of this response
*/
public DefaultHttpResponse(HttpVersion version, HttpResponseStatus status) {
super(version);
@ -39,21 +39,33 @@ public class DefaultHttpResponse extends DefaultHttpMessage implements HttpRespo
}
@Override
public HttpResponseStatus status() {
public HttpResponseStatus getStatus() {
return status;
}
@Override
public HttpResponse setStatus(HttpResponseStatus status) {
this.status = status;
return this;
}
@Override
public HttpResponse setProtocolVersion(HttpVersion version) {
super.setProtocolVersion(version);
return this;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append(getClass().getSimpleName());
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().toString());
buf.append(getStatus().toString());
buf.append(StringUtil.NEWLINE);
appendHeaders(buf);

View File

@ -22,4 +22,5 @@ package io.netty.handler.codec.http;
public interface FullHttpMessage extends HttpMessage, LastHttpContent {
@Override
FullHttpMessage copy();
}

View File

@ -22,4 +22,13 @@ package io.netty.handler.codec.http;
public interface FullHttpRequest extends HttpRequest, FullHttpMessage {
@Override
FullHttpRequest copy();
@Override
FullHttpRequest setProtocolVersion(HttpVersion version);
@Override
FullHttpRequest setMethod(HttpMethod method);
@Override
FullHttpRequest setUri(String uri);
}

View File

@ -22,4 +22,10 @@ package io.netty.handler.codec.http;
public interface FullHttpResponse extends HttpResponse, FullHttpMessage {
@Override
FullHttpResponse copy();
@Override
FullHttpResponse setProtocolVersion(HttpVersion version);
@Override
FullHttpResponse setStatus(HttpResponseStatus status);
}

View File

@ -85,7 +85,7 @@ public class HttpClientCodec extends CombinedChannelHandler {
protected void encode(
ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
if (msg instanceof HttpRequest && !done) {
queue.offer(((HttpRequest) msg).method());
queue.offer(((HttpRequest) msg).getMethod());
}
super.encode(ctx, msg, out);
@ -138,13 +138,13 @@ public class HttpClientCodec extends CombinedChannelHandler {
@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;
}
// Get the method of the HTTP request that corresponds to the
// Get the getMethod of the HTTP request that corresponds to the
// current response.
HttpMethod method = queue.poll();
@ -152,7 +152,7 @@ public class HttpClientCodec extends CombinedChannelHandler {
switch (firstChar) {
case 'H':
// According to 4.3, RFC2616:
// All responses to the HEAD request method MUST NOT include a
// All responses to the HEAD request getMethod MUST NOT include a
// message-body, even though the presence of entity-header fields
// might lead one to believe they do.
if (HttpMethod.HEAD.equals(method)) {

View File

@ -56,7 +56,7 @@ public abstract class HttpContentDecoder extends MessageToMessageDecoder<Object>
@Override
protected Object decode(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof HttpResponse && ((HttpResponse) msg).status().code() == 100) {
if (msg instanceof HttpResponse && ((HttpResponse) msg).getStatus().code() == 100) {
// 100-continue response must be passed through.
return msg;
}
@ -163,7 +163,7 @@ public abstract class HttpContentDecoder extends MessageToMessageDecoder<Object>
/**
* Returns the expected content encoding of the decoded content.
* This method returns {@code "identity"} by default, which is the case for
* This getMethod returns {@code "identity"} by default, which is the case for
* most decoders.
*
* @param contentEncoding the value of the {@code "Content-Encoding"} header

View File

@ -79,7 +79,7 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpMessa
public Object encode(ChannelHandlerContext ctx, Object msg)
throws Exception {
if (msg instanceof HttpResponse && ((HttpResponse) msg).status().code() == 100) {
if (msg instanceof HttpResponse && ((HttpResponse) msg).getStatus().code() == 100) {
// 100-continue response must be passed through.
return msg;
}
@ -91,11 +91,11 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpMessa
if (msg instanceof HttpContent) {
if (msg instanceof HttpRequest) {
HttpRequest req = (HttpRequest) msg;
message = new DefaultHttpRequest(req.protocolVersion(), req.method(), req.uri());
message = new DefaultHttpRequest(req.getProtocolVersion(), req.getMethod(), req.getUri());
message.headers().set(req.headers());
} else if (msg instanceof HttpResponse) {
HttpResponse res = (HttpResponse) msg;
message = new DefaultHttpResponse(res.protocolVersion(), res.status());
message = new DefaultHttpResponse(res.getProtocolVersion(), res.getStatus());
message.headers().set(res.headers());
} else {
return msg;

View File

@ -557,7 +557,7 @@ public abstract class HttpHeaders implements Iterable<Map.Entry<String, String>>
return false;
}
if (message.protocolVersion().isKeepAliveDefault()) {
if (message.getProtocolVersion().isKeepAliveDefault()) {
return !Values.CLOSE.equalsIgnoreCase(connection);
} else {
return Values.KEEP_ALIVE.equalsIgnoreCase(connection);
@ -566,7 +566,7 @@ public abstract class HttpHeaders implements Iterable<Map.Entry<String, String>>
/**
* Sets the value of the {@code "Connection"} header depending on the
* protocol version of the specified message. This method sets or removes
* protocol version of the specified message. This getMethod sets or removes
* the {@code "Connection"} header depending on what the default keep alive
* mode of the message's protocol version is, as specified by
* {@link HttpVersion#isKeepAliveDefault()}.
@ -585,7 +585,7 @@ public abstract class HttpHeaders implements Iterable<Map.Entry<String, String>>
*/
public static void setKeepAlive(HttpMessage message, boolean keepAlive) {
HttpHeaders h = message.headers();
if (message.protocolVersion().isKeepAliveDefault()) {
if (message.getProtocolVersion().isKeepAliveDefault()) {
if (keepAlive) {
h.remove(Names.CONNECTION);
} else {
@ -642,7 +642,7 @@ public abstract class HttpHeaders implements Iterable<Map.Entry<String, String>>
/**
* Sets a new header with the specified name and values. If there is an
* existing header with the same name, the existing header is removed.
* This method can be represented approximately as the following code:
* This getMethod can be represented approximately as the following code:
* <pre>
* removeHeader(message, name);
* for (Object v: values) {
@ -883,14 +883,14 @@ public abstract class HttpHeaders implements Iterable<Map.Entry<String, String>>
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(Names.SEC_WEBSOCKET_KEY1) &&
h.contains(Names.SEC_WEBSOCKET_KEY2)) {
return 8;
}
} else if (message instanceof HttpResponse) {
HttpResponse res = (HttpResponse) message;
if (res.status().code() == 101 &&
if (res.getStatus().code() == 101 &&
h.contains(Names.SEC_WEBSOCKET_ORIGIN) &&
h.contains(Names.SEC_WEBSOCKET_LOCATION)) {
return 16;
@ -971,7 +971,7 @@ public abstract class HttpHeaders implements Iterable<Map.Entry<String, String>>
}
// 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;
}
@ -1232,7 +1232,7 @@ public abstract class HttpHeaders implements Iterable<Map.Entry<String, String>>
/**
* Adds a new header with the specified name and values.
*
* This method can be represented approximately as the following code:
* This getMethod can be represented approximately as the following code:
* <pre>
* for (Object v: values) {
* if (v == null) {
@ -1282,7 +1282,7 @@ public abstract class HttpHeaders implements Iterable<Map.Entry<String, String>>
* Sets a header with the specified name and values.
*
* If there is an existing header with the same name, it is removed.
* This method can be represented approximately as the following code:
* This getMethod can be represented approximately as the following code:
* <pre>
* headers.remove(name);
* for (Object v: values) {

View File

@ -33,7 +33,12 @@ public interface HttpMessage extends HttpObject {
*
* @return The protocol version
*/
HttpVersion protocolVersion();
HttpVersion getProtocolVersion();
/**
* Set the protocol version of this {@link HttpMessage}
*/
HttpMessage setProtocolVersion(HttpVersion version);
/**
* Returns the headers of this message.

View File

@ -19,15 +19,15 @@ import java.util.HashMap;
import java.util.Map;
/**
* The request method of HTTP or its derived protocols, such as
* The request getMethod of HTTP or its derived protocols, such as
* <a href="http://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol">RTSP</a> and
* <a href="http://en.wikipedia.org/wiki/Internet_Content_Adaptation_Protocol">ICAP</a>.
* @apiviz.exclude
*/
public class HttpMethod implements Comparable<HttpMethod> {
/**
* The OPTIONS method represents a request for information about the communication options
* available on the request/response chain identified by the Request-URI. This method allows
* The OPTIONS getMethod represents a request for information about the communication options
* available on the request/response chain identified by the Request-URI. This getMethod allows
* the client to determine the options and/or requirements associated with a resource, or the
* capabilities of a server, without implying a resource action or initiating a resource
* retrieval.
@ -35,7 +35,7 @@ public class HttpMethod implements Comparable<HttpMethod> {
public static final HttpMethod OPTIONS = new HttpMethod("OPTIONS");
/**
* The GET method means retrieve whatever information (in the form of an entity) is identified
* The GET getMethod means retrieve whatever information (in the form of an entity) is identified
* by the Request-URI. If the Request-URI refers to a data-producing process, it is the
* produced data which shall be returned as the entity in the response and not the source text
* of the process, unless that text happens to be the output of the process.
@ -43,43 +43,43 @@ public class HttpMethod implements Comparable<HttpMethod> {
public static final HttpMethod GET = new HttpMethod("GET");
/**
* The HEAD method is identical to GET except that the server MUST NOT return a message-body
* The HEAD getMethod is identical to GET except that the server MUST NOT return a message-body
* in the response.
*/
public static final HttpMethod HEAD = new HttpMethod("HEAD");
/**
* The POST method is used to request that the origin server accept the entity enclosed in the
* The POST getMethod is used to request that the origin server accept the entity enclosed in the
* request as a new subordinate of the resource identified by the Request-URI in the
* Request-Line.
*/
public static final HttpMethod POST = new HttpMethod("POST");
/**
* The PUT method requests that the enclosed entity be stored under the supplied Request-URI.
* The PUT getMethod requests that the enclosed entity be stored under the supplied Request-URI.
*/
public static final HttpMethod PUT = new HttpMethod("PUT");
/**
* The PATCH method requests that a set of changes described in the
* The PATCH getMethod requests that a set of changes described in the
* request entity be applied to the resource identified by the Request-URI.
*/
public static final HttpMethod PATCH = new HttpMethod("PATCH");
/**
* The DELETE method requests that the origin server delete the resource identified by the
* The DELETE getMethod requests that the origin server delete the resource identified by the
* Request-URI.
*/
public static final HttpMethod DELETE = new HttpMethod("DELETE");
/**
* The TRACE method is used to invoke a remote, application-layer loop- back of the request
* The TRACE getMethod is used to invoke a remote, application-layer loop- back of the request
* message.
*/
public static final HttpMethod TRACE = new HttpMethod("TRACE");
/**
* This specification reserves the method name CONNECT for use with a proxy that can dynamically
* This specification reserves the getMethod name CONNECT for use with a proxy that can dynamically
* switch to being a tunnel
*/
public static final HttpMethod CONNECT = new HttpMethod("CONNECT");
@ -101,7 +101,7 @@ public class HttpMethod implements Comparable<HttpMethod> {
/**
* Returns the {@link HttpMethod} represented by the specified name.
* If the specified name is a standard HTTP method name, a cached instance
* If the specified name is a standard HTTP getMethod name, a cached instance
* will be returned. Otherwise, a new instance will be returned.
*/
public static HttpMethod valueOf(String name) {
@ -125,8 +125,8 @@ public class HttpMethod implements Comparable<HttpMethod> {
private final String name;
/**
* Creates a new HTTP method with the specified name. You will not need to
* create a new method unless you are implementing a protocol derived from
* Creates a new HTTP getMethod with the specified name. You will not need to
* create a new getMethod unless you are implementing a protocol derived from
* HTTP, such as
* <a href="http://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol">RTSP</a> and
* <a href="http://en.wikipedia.org/wiki/Internet_Content_Adaptation_Protocol">ICAP</a>
@ -152,7 +152,7 @@ public class HttpMethod implements Comparable<HttpMethod> {
}
/**
* Returns the name of this method.
* Returns the name of this getMethod.
*/
public String name() {
return name;

View File

@ -21,11 +21,11 @@ public interface HttpObject {
/**
* 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}.
* Do not call this method unless you know what you are doing.
*/
void updateDecoderResult(DecoderResult result);
void setDecoderResult(DecoderResult result);
}

View File

@ -126,19 +126,19 @@ public class HttpObjectAggregator extends MessageToMessageDecoder<HttpObject> {
ctx.write(CONTINUE.duplicate());
}
if (!m.decoderResult().isSuccess()) {
if (!m.getDecoderResult().isSuccess()) {
removeTransferEncodingChunked(m);
this.currentMessage = null;
return m;
}
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();
@ -177,9 +177,9 @@ public class HttpObjectAggregator extends MessageToMessageDecoder<HttpObject> {
}
final boolean last;
if (!chunk.decoderResult().isSuccess()) {
currentMessage.updateDecoderResult(
DecoderResult.partialFailure(chunk.decoderResult().cause()));
if (!chunk.getDecoderResult().isSuccess()) {
currentMessage.setDecoderResult(
DecoderResult.partialFailure(chunk.getDecoderResult().cause()));
last = true;
} else {
last = msg instanceof LastHttpContent;

View File

@ -404,7 +404,7 @@ public abstract class HttpObjectDecoder extends ReplayingDecoder<HttpObjectDecod
protected boolean isContentAlwaysEmpty(HttpMessage msg) {
if (msg instanceof HttpResponse) {
HttpResponse res = (HttpResponse) msg;
int code = res.status().code();
int code = res.getStatus().code();
// Correctly handle return codes of 1xx.
//
@ -449,10 +449,10 @@ public abstract class HttpObjectDecoder extends ReplayingDecoder<HttpObjectDecod
private HttpMessage invalidMessage(Exception cause) {
checkpoint(State.BAD_MESSAGE);
if (message != null) {
message.updateDecoderResult(DecoderResult.partialFailure(cause));
message.setDecoderResult(DecoderResult.partialFailure(cause));
} else {
message = createInvalidMessage();
message.updateDecoderResult(DecoderResult.failure(cause));
message.setDecoderResult(DecoderResult.failure(cause));
}
return message;
}
@ -460,7 +460,7 @@ public abstract class HttpObjectDecoder extends ReplayingDecoder<HttpObjectDecod
private HttpContent invalidChunk(Exception cause) {
checkpoint(State.BAD_MESSAGE);
HttpContent chunk = new DefaultHttpContent(Unpooled.EMPTY_BUFFER);
chunk.updateDecoderResult(DecoderResult.failure(cause));
chunk.setDecoderResult(DecoderResult.failure(cause));
return chunk;
}

View File

@ -38,12 +38,25 @@ public interface HttpRequest extends HttpMessage {
*
* @return The {@link HttpMethod} of this {@link HttpRequest}
*/
HttpMethod method();
HttpMethod getMethod();
/**
* Set the {@link HttpMethod} of this {@link HttpRequest}.
*/
HttpRequest setMethod(HttpMethod method);
/**
* Returns the requested URI (or alternatively, path)
*
* @return The URI being requested
*/
String uri();
String getUri();
/**
* Set the requested URI (or alternatively, path)
*/
HttpRequest setUri(String uri);
@Override
HttpRequest setProtocolVersion(HttpVersion version);
}

View File

@ -34,12 +34,12 @@ public class HttpRequestEncoder extends HttpObjectEncoder<HttpRequest> {
@Override
protected void encodeInitialLine(ByteBuf buf, HttpRequest request) throws Exception {
buf.writeBytes(request.method().toString().getBytes(CharsetUtil.US_ASCII));
buf.writeBytes(request.getMethod().toString().getBytes(CharsetUtil.US_ASCII));
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();
int start = uri.indexOf("://");
if (start != -1) {
int startIndex = start + 3;
@ -50,7 +50,7 @@ public class HttpRequestEncoder extends HttpObjectEncoder<HttpRequest> {
buf.writeBytes(uri.getBytes("UTF-8"));
buf.writeByte(SP);
buf.writeBytes(request.protocolVersion().toString().getBytes(CharsetUtil.US_ASCII));
buf.writeBytes(request.getProtocolVersion().toString().getBytes(CharsetUtil.US_ASCII));
buf.writeByte(CR);
buf.writeByte(LF);
}

View File

@ -36,5 +36,13 @@ public interface HttpResponse extends HttpMessage {
*
* @return The {@link HttpResponseStatus} of this {@link HttpResponse}
*/
HttpResponseStatus status();
HttpResponseStatus getStatus();
/**
* Set the status of this {@link HttpResponse}.
*/
HttpResponse setStatus(HttpResponseStatus status);
@Override
HttpResponse setProtocolVersion(HttpVersion version);
}

View File

@ -33,11 +33,11 @@ public class HttpResponseEncoder extends HttpObjectEncoder<HttpResponse> {
@Override
protected void encodeInitialLine(ByteBuf buf, HttpResponse response) throws Exception {
buf.writeBytes(response.protocolVersion().toString().getBytes(CharsetUtil.US_ASCII));
buf.writeBytes(response.getProtocolVersion().toString().getBytes(CharsetUtil.US_ASCII));
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);
buf.writeBytes(String.valueOf(response.status().reasonPhrase()).getBytes(CharsetUtil.US_ASCII));
buf.writeBytes(String.valueOf(response.getStatus().reasonPhrase()).getBytes(CharsetUtil.US_ASCII));
buf.writeByte(CR);
buf.writeByte(LF);
}

View File

@ -283,7 +283,7 @@ public class HttpResponseStatus implements Comparable<HttpResponseStatus> {
/**
* Returns the {@link HttpResponseStatus} represented by the specified code.
* If the specified code is a standard HTTP status code, a cached instance
* If the specified code is a standard HTTP getStatus code, a cached instance
* will be returned. Otherwise, a new instance will be returned.
*/
public static HttpResponseStatus valueOf(int code) {
@ -445,14 +445,14 @@ public class HttpResponseStatus implements Comparable<HttpResponseStatus> {
}
/**
* Returns the code of this status.
* Returns the code of this getStatus.
*/
public int code() {
return code;
}
/**
* Returns the reason phrase of this status.
* Returns the reason phrase of this getStatus.
*/
public String reasonPhrase() {
return reasonPhrase;

View File

@ -45,12 +45,12 @@ public interface LastHttpContent extends HttpContent {
}
@Override
public DecoderResult decoderResult() {
public DecoderResult getDecoderResult() {
return DecoderResult.SUCCESS;
}
@Override
public void updateDecoderResult(DecoderResult result) {
public void setDecoderResult(DecoderResult result) {
throw new UnsupportedOperationException("read only");
}

View File

@ -106,7 +106,7 @@ public class QueryStringDecoder {
*/
public QueryStringDecoder(String uri, Charset charset, boolean hasPath, int maxParams) {
if (uri == null) {
throw new NullPointerException("uri");
throw new NullPointerException("getUri");
}
if (charset == null) {
throw new NullPointerException("charset");
@ -145,7 +145,7 @@ public class QueryStringDecoder {
*/
public QueryStringDecoder(URI uri, Charset charset, int maxParams) {
if (uri == null) {
throw new NullPointerException("uri");
throw new NullPointerException("getUri");
}
if (charset == null) {
throw new NullPointerException("charset");

View File

@ -58,7 +58,7 @@ public class QueryStringEncoder {
*/
public QueryStringEncoder(String uri, Charset charset) {
if (uri == null) {
throw new NullPointerException("uri");
throw new NullPointerException("getUri");
}
if (charset == null) {
throw new NullPointerException("charset");
@ -84,7 +84,7 @@ public class QueryStringEncoder {
/**
* Returns the URL-encoded URI object which was created from the path string
* specified in the constructor and the parameters added by
* {@link #addParam(String, String)} method.
* {@link #addParam(String, String)} getMethod.
*/
public URI toUri() throws URISyntaxException {
return new URI(toString());
@ -93,7 +93,7 @@ public class QueryStringEncoder {
/**
* Returns the URL-encoded URI which was created from the path string
* specified in the constructor and the parameters added by
* {@link #addParam(String, String)} method.
* {@link #addParam(String, String)} getMethod.
*/
@Override
public String toString() {

View File

@ -149,8 +149,8 @@ public interface HttpData extends InterfaceHttpData, ByteBufHolder {
Charset getCharset();
/**
* A convenience method to write an uploaded item to disk. If a previous one
* exists, it will be deleted. Once this method is called, if successful,
* A convenience getMethod to write an uploaded item to disk. If a previous one
* exists, it will be deleted. Once this getMethod is called, if successful,
* the new file will be out of the cleaner of the factory that creates the
* original InterfaceHttpData object.
*

View File

@ -105,7 +105,7 @@ public class HttpPostRequestDecoder {
private String multipartMixedBoundary;
/**
* Current status
* Current getStatus
*/
private MultiPartStatus currentStatus = MultiPartStatus.NOTSTARTED;
@ -188,7 +188,7 @@ public class HttpPostRequestDecoder {
throw new NullPointerException("charset");
}
this.request = request;
HttpMethod method = request.method();
HttpMethod method = request.getMethod();
if (method.equals(HttpMethod.POST) || method.equals(HttpMethod.PUT) || method.equals(HttpMethod.PATCH)) {
bodyToDecode = true;
}
@ -216,7 +216,7 @@ public class HttpPostRequestDecoder {
* MIXEDDISPOSITION MIXEDFILEUPLOAD)+ MIXEDCLOSEDELIMITER)* CLOSEDELIMITER)+
* EPILOGUE
*
* First status is: NOSTARTED
* First getStatus is: NOSTARTED
*
* Content-type: multipart/form-data, boundary=AaB03x => PREAMBLE in Header
*
@ -238,7 +238,7 @@ public class HttpPostRequestDecoder {
* ...contents of file2.gif... => MIXEDFILEUPLOAD --BbC04y-- =>
* MIXEDCLOSEDELIMITER --AaB03x-- => CLOSEDELIMITER
*
* Once CLOSEDELIMITER is found, last status is EPILOGUE
* Once CLOSEDELIMITER is found, last getStatus is EPILOGUE
*/
private enum MultiPartStatus {
NOTSTARTED, PREAMBLE, HEADERDELIMITER, DISPOSITION, FIELD, FILEUPLOAD, MIXEDPREAMBLE, MIXEDDELIMITER,
@ -276,12 +276,12 @@ public class HttpPostRequestDecoder {
}
/**
* This method returns a List of all HttpDatas from body.<br>
* This getMethod returns a List of all HttpDatas from body.<br>
*
* If chunked, all chunks must have been offered using offer() method. If
* If chunked, all chunks must have been offered using offer() getMethod. If
* not, NotEnoughDataDecoderException will be raised.
*
* @return the list of HttpDatas from Body part for POST method
* @return the list of HttpDatas from Body part for POST getMethod
* @throws NotEnoughDataDecoderException
* Need more chunks
*/
@ -293,10 +293,10 @@ public class HttpPostRequestDecoder {
}
/**
* This method returns a List of all HttpDatas with the given name from
* This getMethod returns a List of all HttpDatas with the given name from
* body.<br>
*
* If chunked, all chunks must have been offered using offer() method. If
* If chunked, all chunks must have been offered using offer() getMethod. If
* not, NotEnoughDataDecoderException will be raised.
*
* @return All Body HttpDatas with the given name (ignore case)
@ -311,10 +311,10 @@ public class HttpPostRequestDecoder {
}
/**
* This method returns the first InterfaceHttpData with the given name from
* This getMethod returns the first InterfaceHttpData with the given name from
* body.<br>
*
* If chunked, all chunks must have been offered using offer() method. If
* If chunked, all chunks must have been offered using offer() getMethod. If
* not, NotEnoughDataDecoderException will be raised.
*
* @return The first Body InterfaceHttpData with the given name (ignore
@ -359,12 +359,12 @@ public class HttpPostRequestDecoder {
}
/**
* True if at current status, there is an available decoded
* True if at current getStatus, there is an available decoded
* InterfaceHttpData from the Body.
*
* This method works for chunked and not chunked request.
* This getMethod works for chunked and not chunked request.
*
* @return True if at current status, there is a decoded InterfaceHttpData
* @return True if at current getStatus, there is a decoded InterfaceHttpData
* @throws EndOfDataDecoderException
* No more data will be available
*/
@ -395,7 +395,7 @@ public class HttpPostRequestDecoder {
}
/**
* This method will parse as much as possible data and fill the list and map
* This getMethod will parse as much as possible data and fill the list and map
*
* @throws ErrorDataDecoderException
* if there is a problem with the charset decoding or other
@ -432,7 +432,7 @@ public class HttpPostRequestDecoder {
}
/**
* This method fill the map and list with as much Attribute as possible from
* This getMethod fill the map and list with as much Attribute as possible from
* Body in not Multipart mode.
*
* @throws ErrorDataDecoderException
@ -524,7 +524,7 @@ public class HttpPostRequestDecoder {
return;
}
if (contRead && currentAttribute != null) {
// reset index except if to continue in case of FIELD status
// reset index except if to continue in case of FIELD getStatus
if (currentStatus == MultiPartStatus.FIELD) {
currentAttribute.addContent(undecodedChunk.slice(firstpos, currentpos - firstpos), false);
firstpos = currentpos;
@ -545,7 +545,7 @@ public class HttpPostRequestDecoder {
}
/**
* This method fill the map and list with as much Attribute as possible from
* This getMethod fill the map and list with as much Attribute as possible from
* Body in not Multipart mode.
*
* @throws ErrorDataDecoderException
@ -653,7 +653,7 @@ public class HttpPostRequestDecoder {
return;
}
if (contRead && currentAttribute != null) {
// reset index except if to continue in case of FIELD status
// reset index except if to continue in case of FIELD getStatus
if (currentStatus == MultiPartStatus.FIELD) {
currentAttribute.addContent(undecodedChunk.slice(firstpos, currentpos - firstpos), false);
firstpos = currentpos;
@ -740,10 +740,10 @@ public class HttpPostRequestDecoder {
private InterfaceHttpData decodeMultipart(MultiPartStatus state) throws ErrorDataDecoderException {
switch (state) {
case NOTSTARTED:
throw new ErrorDataDecoderException("Should not be called with the current status");
throw new ErrorDataDecoderException("Should not be called with the current getStatus");
case PREAMBLE:
// Content-type: multipart/form-data, boundary=AaB03x
throw new ErrorDataDecoderException("Should not be called with the current status");
throw new ErrorDataDecoderException("Should not be called with the current getStatus");
case HEADERDELIMITER: {
// --AaB03x or --AaB03x--
return findMultipartDelimiter(multipartDataBoundary, MultiPartStatus.DISPOSITION,
@ -870,9 +870,9 @@ public class HttpPostRequestDecoder {
* @param delimiter
* delimiter to find
* @param dispositionStatus
* the next status if the delimiter is a start
* the next getStatus if the delimiter is a start
* @param closeDelimiterStatus
* the next status if the delimiter is a close delimiter
* the next getStatus if the delimiter is a close delimiter
* @return the next InterfaceHttpData if any
* @throws ErrorDataDecoderException
*/
@ -2045,7 +2045,7 @@ public class HttpPostRequestDecoder {
}
/**
* Exception when an unappropriated method was called on a request
* Exception when an unappropriated getMethod was called on a request
*/
public static class IncompatibleDataDecoderException extends Exception {
private static final long serialVersionUID = -953268047926250267L;

View File

@ -150,7 +150,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput<HttpContent>
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;
@ -231,7 +231,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput<HttpContent>
}
/**
* This method returns a List of all InterfaceHttpData from body part.<br>
* This getMethod returns a List of all InterfaceHttpData from body part.<br>
* @return the list of InterfaceHttpData from Body part
*/
@ -890,7 +890,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput<HttpContent>
/**
* Returns the next available HttpChunk. The caller is responsible to test if this chunk is the last one (isLast()),
* in order to stop calling this method.
* in order to stop calling this getMethod.
*
* @return the next available HttpChunk
* @throws ErrorDataEncoderException
@ -908,7 +908,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput<HttpContent>
/**
* Returns the next available HttpChunk. The caller is responsible to test if this chunk is the last one (isLast()),
* in order to stop calling this method.
* in order to stop calling this getMethod.
*
* @return the next available HttpChunk
* @throws ErrorDataEncoderException

View File

@ -34,7 +34,7 @@ public class CloseWebSocketFrame extends WebSocketFrame {
}
/**
* Creates a new empty close frame with closing status code and reason text
* Creates a new empty close frame with closing getStatus code and reason text
*
* @param statusCode
* Integer status code as per <a href="http://tools.ietf.org/html/rfc6455#section-7.4">RFC 6455</a>. For
@ -47,7 +47,7 @@ public class CloseWebSocketFrame extends WebSocketFrame {
}
/**
* Creates a new close frame with no losing status code and no reason text
* Creates a new close frame with no losing getStatus code and no reason text
*
* @param finalFragment
* flag indicating if this frame is the final fragment
@ -107,7 +107,7 @@ public class CloseWebSocketFrame extends WebSocketFrame {
/**
* Returns the closing status code as per <a href="http://tools.ietf.org/html/rfc6455#section-7.4">RFC 6455</a>. If
* a status code is set, -1 is returned.
* a getStatus code is set, -1 is returned.
*/
public int statusCode() {
ByteBuf binaryData = data();

View File

@ -178,7 +178,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
// close frame : if there is a body, the first two bytes of the
// body MUST be a 2-byte unsigned integer (in network byte
// order) representing a status code
// order) representing a getStatus code
if (frameOpcode == 8 && framePayloadLen1 == 1) {
protocolViolation(ctx, "received close control frame with payload len 1");
return null;
@ -417,7 +417,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
int statusCode = buffer.readShort();
if (statusCode >= 0 && statusCode <= 999 || statusCode >= 1004 && statusCode <= 1006
|| statusCode >= 1012 && statusCode <= 2999) {
protocolViolation(ctx, "Invalid close frame status code: " + statusCode);
protocolViolation(ctx, "Invalid close frame getStatus code: " + statusCode);
}
// May have UTF-8 message

View File

@ -221,8 +221,8 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
public void finishHandshake(Channel channel, FullHttpResponse response) {
final HttpResponseStatus status = new HttpResponseStatus(101, "WebSocket Protocol Handshake");
if (!response.status().equals(status)) {
throw new WebSocketHandshakeException("Invalid handshake response status: " + response.status());
if (!response.getStatus().equals(status)) {
throw new WebSocketHandshakeException("Invalid handshake response getStatus: " + response.getStatus());
}
HttpHeaders headers = response.headers();

View File

@ -198,8 +198,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 status: " + response.status());
if (!response.getStatus().equals(status)) {
throw new WebSocketHandshakeException("Invalid handshake response getStatus: " + response.getStatus());
}
String upgrade = headers.get(Names.UPGRADE);

View File

@ -198,8 +198,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 status: " + response.status());
if (!response.getStatus().equals(status)) {
throw new WebSocketHandshakeException("Invalid handshake response getStatus: " + response.getStatus());
}
String upgrade = headers.get(Names.UPGRADE);

View File

@ -197,8 +197,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 status: " + response.status());
if (!response.getStatus().equals(status)) {
throw new WebSocketHandshakeException("Invalid handshake response getStatus: " + response.getStatus());
}
String upgrade = headers.get(Names.UPGRADE);

View File

@ -140,9 +140,9 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
res.headers().add(Names.UPGRADE, WEBSOCKET);
res.headers().add(CONNECTION, Values.UPGRADE);
// Fill in the headers and contents depending on handshake method.
// Fill in the headers and contents depending on handshake getMethod.
if (isHixie76) {
// New handshake method with a challenge:
// New handshake getMethod with a challenge:
res.headers().add(SEC_WEBSOCKET_ORIGIN, req.headers().get(ORIGIN));
res.headers().add(SEC_WEBSOCKET_LOCATION, uri());
String subprotocols = req.headers().get(SEC_WEBSOCKET_PROTOCOL);
@ -170,7 +170,7 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
input.writeLong(c);
res.data().writeBytes(WebSocketUtil.md5(input.array()));
} else {
// Old Hixie 75 handshake method with no challenge:
// Old Hixie 75 handshake getMethod with no challenge:
res.headers().add(WEBSOCKET_ORIGIN, req.headers().get(ORIGIN));
res.headers().add(WEBSOCKET_LOCATION, uri());
String protocol = req.headers().get(WEBSOCKET_PROTOCOL);

View File

@ -52,7 +52,7 @@ public class WebSocketServerProtocolHandshakeHandler
@Override
public void messageReceived(final ChannelHandlerContext ctx, FullHttpRequest req) throws Exception {
if (req.method() != GET) {
if (req.getMethod() != GET) {
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN));
return;
}
@ -80,7 +80,7 @@ public class WebSocketServerProtocolHandshakeHandler
private static void sendHttpResponse(ChannelHandlerContext ctx, HttpRequest req, HttpResponse res) {
ChannelFuture f = ctx.channel().write(res);
if (!isKeepAlive(req) || res.status().code() != 200) {
if (!isKeepAlive(req) || res.getStatus().code() != 200) {
f.addListener(ChannelFutureListener.CLOSE);
}
}

View File

@ -21,14 +21,14 @@ import java.util.HashMap;
import java.util.Map;
/**
* The request method of RTSP.
* The request getMethod of RTSP.
* @apiviz.exclude
*/
public final class RtspMethods {
/**
* The OPTIONS method represents a request for information about the communication options
* available on the request/response chain identified by the Request-URI. This method allows
* The OPTIONS getMethod represents a request for information about the communication options
* available on the request/response chain identified by the Request-URI. This getMethod allows
* the client to determine the options and/or requirements associated with a resource, or the
* capabilities of a server, without implying a resource action or initiating a resource
* retrieval.
@ -36,7 +36,7 @@ public final class RtspMethods {
public static final HttpMethod OPTIONS = HttpMethod.OPTIONS;
/**
* The DESCRIBE method retrieves the description of a presentation or
* The DESCRIBE getMethod retrieves the description of a presentation or
* media object identified by the request URL from a server.
*/
public static final HttpMethod DESCRIBE = new HttpMethod("DESCRIBE");
@ -55,7 +55,7 @@ public final class RtspMethods {
public static final HttpMethod SETUP = new HttpMethod("SETUP");
/**
* The PLAY method tells the server to start sending data via the
* The PLAY getMethod tells the server to start sending data via the
* mechanism specified in SETUP.
*/
public static final HttpMethod PLAY = new HttpMethod("PLAY");
@ -91,7 +91,7 @@ public final class RtspMethods {
public static final HttpMethod REDIRECT = new HttpMethod("REDIRECT");
/**
* The RECORD method initiates recording a range of media data according to
* The RECORD getMethod initiates recording a range of media data according to
* the presentation description.
*/
public static final HttpMethod RECORD = new HttpMethod("RECORD");
@ -114,7 +114,7 @@ public final class RtspMethods {
/**
* Returns the {@link HttpMethod} represented by the specified name.
* If the specified name is a standard RTSP method name, a cached instance
* If the specified name is a standard RTSP getMethod name, a cached instance
* will be returned. Otherwise, a new instance will be returned.
*/
public static HttpMethod valueOf(String name) {

View File

@ -35,11 +35,11 @@ public class RtspRequestEncoder extends RtspObjectEncoder<HttpRequest> {
@Override
protected void encodeInitialLine(ByteBuf buf, HttpRequest request)
throws Exception {
buf.writeBytes(request.method().toString().getBytes(CharsetUtil.US_ASCII));
buf.writeBytes(request.getMethod().toString().getBytes(CharsetUtil.US_ASCII));
buf.writeByte((byte) ' ');
buf.writeBytes(request.uri().getBytes(CharsetUtil.UTF_8));
buf.writeBytes(request.getUri().getBytes(CharsetUtil.UTF_8));
buf.writeByte((byte) ' ');
buf.writeBytes(request.protocolVersion().toString().getBytes(CharsetUtil.US_ASCII));
buf.writeBytes(request.getProtocolVersion().toString().getBytes(CharsetUtil.US_ASCII));
buf.writeByte((byte) '\r');
buf.writeByte((byte) '\n');
}

View File

@ -35,11 +35,11 @@ public class RtspResponseEncoder extends RtspObjectEncoder<HttpResponse> {
@Override
protected void encodeInitialLine(ByteBuf buf, HttpResponse response)
throws Exception {
buf.writeBytes(response.protocolVersion().toString().getBytes(CharsetUtil.US_ASCII));
buf.writeBytes(response.getProtocolVersion().toString().getBytes(CharsetUtil.US_ASCII));
buf.writeByte((byte) ' ');
buf.writeBytes(String.valueOf(response.status().code()).getBytes(CharsetUtil.US_ASCII));
buf.writeBytes(String.valueOf(response.getStatus().code()).getBytes(CharsetUtil.US_ASCII));
buf.writeByte((byte) ' ');
buf.writeBytes(String.valueOf(response.status().reasonPhrase()).getBytes(CharsetUtil.US_ASCII));
buf.writeBytes(String.valueOf(response.getStatus().reasonPhrase()).getBytes(CharsetUtil.US_ASCII));
buf.writeByte((byte) '\r');
buf.writeByte((byte) '\n');
}

View File

@ -18,7 +18,7 @@ package io.netty.handler.codec.rtsp;
import io.netty.handler.codec.http.HttpResponseStatus;
/**
* The status code and its description of a RTSP response.
* The getStatus code and its description of a RTSP response.
* @apiviz.exclude
*/
public final class RtspResponseStatuses {
@ -262,7 +262,7 @@ public final class RtspResponseStatuses {
/**
* Returns the {@link HttpResponseStatus} represented by the specified code.
* If the specified code is a standard RTSP status code, a cached instance
* If the specified code is a standard RTSP getStatus code, a cached instance
* will be returned. Otherwise, a new instance will be returned.
*/
public static HttpResponseStatus valueOf(int code) {

View File

@ -48,7 +48,7 @@ public class DefaultSpdyGoAwayFrame implements SpdyGoAwayFrame {
* Creates a new instance.
*
* @param lastGoodStreamId the Last-good-stream-ID of this frame
* @param status the status of this frame
* @param status the getStatus of this frame
*/
public DefaultSpdyGoAwayFrame(int lastGoodStreamId, SpdySessionStatus status) {
setLastGoodStreamId(lastGoodStreamId);

View File

@ -39,7 +39,7 @@ public class DefaultSpdyRstStreamFrame implements SpdyRstStreamFrame {
* Creates a new instance.
*
* @param streamId the Stream-ID of this frame
* @param status the status of this frame
* @param status the getStatus of this frame
*/
public DefaultSpdyRstStreamFrame(int streamId, SpdyStreamStatus status) {
setStreamId(streamId);

View File

@ -32,12 +32,12 @@ public interface SpdyGoAwayFrame extends SpdyControlFrame {
void setLastGoodStreamId(int lastGoodStreamId);
/**
* Returns the status of this frame.
* Returns the getStatus of this frame.
*/
SpdySessionStatus getStatus();
/**
* Sets the status of this frame.
* Sets the getStatus of this frame.
*/
void setStatus(SpdySessionStatus status);
}

View File

@ -42,9 +42,9 @@ public class SpdyHeaders {
*/
public static final String HOST = ":host";
/**
* {@code ":method"}
* {@code ":getMethod"}
*/
public static final String METHOD = ":method";
public static final String METHOD = ":getMethod";
/**
* {@code ":path"}
*/
@ -54,9 +54,9 @@ public class SpdyHeaders {
*/
public static final String SCHEME = ":scheme";
/**
* {@code ":status"}
* {@code ":getStatus"}
*/
public static final String STATUS = ":status";
public static final String STATUS = ":getStatus";
/**
* {@code ":version"}
*/
@ -71,17 +71,17 @@ public class SpdyHeaders {
*/
public static final class Spdy2HttpNames {
/**
* {@code "method"}
* {@code "getMethod"}
*/
public static final String METHOD = "method";
public static final String METHOD = "getMethod";
/**
* {@code "scheme"}
*/
public static final String SCHEME = "scheme";
/**
* {@code "status"}
* {@code "getStatus"}
*/
public static final String STATUS = "status";
public static final String STATUS = "getStatus";
/**
* {@code "url"}
*/
@ -166,7 +166,7 @@ public class SpdyHeaders {
}
/**
* Removes the HTTP method header.
* Removes the HTTP getMethod header.
*/
public static void removeMethod(int spdyVersion, SpdyHeaderBlock block) {
if (spdyVersion < 3) {
@ -177,7 +177,7 @@ public class SpdyHeaders {
}
/**
* Returns the {@link HttpMethod} represented by the HTTP method header.
* Returns the {@link HttpMethod} represented by the HTTP getMethod header.
*/
public static HttpMethod getMethod(int spdyVersion, SpdyHeaderBlock block) {
try {
@ -192,7 +192,7 @@ public class SpdyHeaders {
}
/**
* Sets the HTTP method header.
* Sets the HTTP getMethod header.
*/
public static void setMethod(int spdyVersion, SpdyHeaderBlock block, HttpMethod method) {
if (spdyVersion < 3) {
@ -236,7 +236,7 @@ public class SpdyHeaders {
}
/**
* Removes the HTTP response status header.
* Removes the HTTP response getStatus header.
*/
public static void removeStatus(int spdyVersion, SpdyHeaderBlock block) {
if (spdyVersion < 3) {
@ -247,7 +247,7 @@ public class SpdyHeaders {
}
/**
* Returns the {@link HttpResponseStatus} represented by the HTTP response status header.
* Returns the {@link HttpResponseStatus} represented by the HTTP response getStatus header.
*/
public static HttpResponseStatus getStatus(int spdyVersion, SpdyHeaderBlock block) {
try {
@ -276,7 +276,7 @@ public class SpdyHeaders {
}
/**
* Sets the HTTP response status header.
* Sets the HTTP response getStatus header.
*/
public static void setStatus(int spdyVersion, SpdyHeaderBlock block, HttpResponseStatus status) {
if (spdyVersion < 3) {

View File

@ -133,7 +133,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder<Object> {
messageMap.put(Integer.valueOf(streamID), httpRequestWithEntity);
}
} catch (Exception e) {
// If a client sends a SYN_STREAM without all of the method, url (host and path),
// If a client sends a SYN_STREAM without all of the getMethod, url (host and path),
// scheme, and version headers the server must reply with a HTTP 400 BAD REQUEST reply.
// Also sends HTTP 400 BAD REQUEST reply if header name/value pairs are invalid
SpdySynReplyFrame spdySynReplyFrame = new DefaultSpdySynReplyFrame(streamID);
@ -163,7 +163,7 @@ public class SpdyHttpDecoder extends MessageToMessageDecoder<Object> {
messageMap.put(Integer.valueOf(streamID), httpResponseWithEntity);
}
} catch (Exception e) {
// If a client receives a SYN_REPLY without valid status and version headers
// If a client receives a SYN_REPLY without valid getStatus and version headers
// the client must reply with a RST_STREAM frame indicating a PROTOCOL_ERROR
SpdyRstStreamFrame spdyRstStreamFrame =
new DefaultSpdyRstStreamFrame(streamID, SpdyStreamStatus.PROTOCOL_ERROR);

View File

@ -219,15 +219,15 @@ public class SpdyHttpEncoder extends MessageToMessageEncoder<Object> {
// 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);
}
@ -271,8 +271,8 @@ public class SpdyHttpEncoder extends MessageToMessageEncoder<Object> {
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<String, String> entry: httpResponse.headers()) {

View File

@ -154,7 +154,7 @@ public abstract class SpdyOrHttpChooser extends ChannelHandlerAdapter implements
* when the {@link SelectedProtocol} was {@link SelectedProtocol#SpdyVersion2} or
* {@link SelectedProtocol#SpdyVersion3}.
*
* Bye default this method will just delecate to {@link #createHttpRequestHandlerForHttp()}, but
* Bye default this getMethod will just delecate to {@link #createHttpRequestHandlerForHttp()}, but
* sub-classes may override this to change the behaviour.
*/
protected ChannelInboundHandler createHttpRequestHandlerForSpdy() {

View File

@ -31,12 +31,12 @@ public interface SpdyRstStreamFrame extends SpdyControlFrame {
void setStreamId(int streamID);
/**
* Returns the status of this frame.
* Returns the getStatus of this frame.
*/
SpdyStreamStatus getStatus();
/**
* Sets the status of this frame.
* Sets the getStatus of this frame.
*/
void setStatus(SpdyStreamStatus status);
}

View File

@ -143,7 +143,7 @@ public class SpdySessionHandler
*
* If an endpoint which created the stream receives a data frame before receiving
* a SYN_REPLY on that stream, it is a protocol error, and the recipient must
* issue a stream error with the status code PROTOCOL_ERROR for the Stream-ID.
* issue a stream error with the getStatus code PROTOCOL_ERROR for the Stream-ID.
*
* If an endpoint receives multiple data frames for invalid Stream-IDs,
* it may close the session.
@ -151,10 +151,10 @@ public class SpdySessionHandler
* If an endpoint refuses a stream it must ignore any data frames for that stream.
*
* If an endpoint receives a data frame after the stream is half-closed from the
* sender, it must send a RST_STREAM frame with the status STREAM_ALREADY_CLOSED.
* sender, it must send a RST_STREAM frame with the getStatus STREAM_ALREADY_CLOSED.
*
* If an endpoint receives a data frame after the stream is closed, it must send
* a RST_STREAM frame with the status PROTOCOL_ERROR.
* a RST_STREAM frame with the getStatus PROTOCOL_ERROR.
*/
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
@ -236,13 +236,13 @@ public class SpdySessionHandler
*
* If an endpoint receives a SYN_STREAM with a Stream-ID that is less than
* any previously received SYN_STREAM, it must issue a session error with
* the status PROTOCOL_ERROR.
* the getStatus PROTOCOL_ERROR.
*
* If an endpoint receives multiple SYN_STREAM frames with the same active
* Stream-ID, it must issue a stream error with the status code PROTOCOL_ERROR.
* Stream-ID, it must issue a stream error with the getStatus code PROTOCOL_ERROR.
*
* The recipient can reject a stream by sending a stream error with the
* status code REFUSED_STREAM.
* getStatus code REFUSED_STREAM.
*/
SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg;
@ -277,7 +277,7 @@ public class SpdySessionHandler
* SPDY SYN_REPLY frame processing requirements:
*
* If an endpoint receives multiple SYN_REPLY frames for the same active Stream-ID
* it must issue a stream error with the status code STREAM_IN_USE.
* it must issue a stream error with the getStatus code STREAM_IN_USE.
*/
SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg;
@ -399,7 +399,7 @@ public class SpdySessionHandler
* SPDY WINDOW_UPDATE frame processing requirements:
*
* Receivers of a WINDOW_UPDATE that cause the window size to exceed 2^31
* must send a RST_STREAM with the status code FLOW_CONTROL_ERROR.
* must send a RST_STREAM with the getStatus code FLOW_CONTROL_ERROR.
*
* Sender should ignore all WINDOW_UPDATE frames associated with a stream
* after sending the last frame for the stream.
@ -689,7 +689,7 @@ public class SpdySessionHandler
* SPDY Stream Error Handling:
*
* Upon a stream error, the endpoint must send a RST_STREAM frame which contains
* the Stream-ID for the stream where the error occurred and the error status which
* the Stream-ID for the stream where the error occurred and the error getStatus which
* caused the error.
*
* After sending the RST_STREAM, the stream is closed to the sending endpoint.

View File

@ -16,7 +16,7 @@
package io.netty.handler.codec.spdy;
/**
* The SPDY session status code and its description.
* The SPDY session getStatus code and its description.
* @apiviz.exclude
*/
public class SpdySessionStatus implements Comparable<SpdySessionStatus> {
@ -41,7 +41,7 @@ public class SpdySessionStatus implements Comparable<SpdySessionStatus> {
/**
* Returns the {@link SpdySessionStatus} represented by the specified code.
* If the specified code is a defined SPDY status code, a cached instance
* If the specified code is a defined SPDY getStatus code, a cached instance
* will be returned. Otherwise, a new instance will be returned.
*/
public static SpdySessionStatus valueOf(int code) {
@ -75,14 +75,14 @@ public class SpdySessionStatus implements Comparable<SpdySessionStatus> {
}
/**
* Returns the code of this status.
* Returns the code of this getStatus.
*/
public int getCode() {
return code;
}
/**
* Returns the status phrase of this status.
* Returns the getStatus phrase of this getStatus.
*/
public String getStatusPhrase() {
return statusPhrase;

View File

@ -16,7 +16,7 @@
package io.netty.handler.codec.spdy;
/**
* The SPDY stream status code and its description.
* The SPDY stream getStatus code and its description.
* @apiviz.exclude
*/
public class SpdyStreamStatus implements Comparable<SpdyStreamStatus> {
@ -89,13 +89,13 @@ public class SpdyStreamStatus implements Comparable<SpdyStreamStatus> {
/**
* Returns the {@link SpdyStreamStatus} represented by the specified code.
* If the specified code is a defined SPDY status code, a cached instance
* If the specified code is a defined SPDY getStatus code, a cached instance
* will be returned. Otherwise, a new instance will be returned.
*/
public static SpdyStreamStatus valueOf(int code) {
if (code == 0) {
throw new IllegalArgumentException(
"0 is not a valid status code for a RST_STREAM");
"0 is not a valid getStatus code for a RST_STREAM");
}
switch (code) {
@ -137,7 +137,7 @@ public class SpdyStreamStatus implements Comparable<SpdyStreamStatus> {
public SpdyStreamStatus(int code, String statusPhrase) {
if (code == 0) {
throw new IllegalArgumentException(
"0 is not a valid status code for a RST_STREAM");
"0 is not a valid getStatus code for a RST_STREAM");
}
if (statusPhrase == null) {
@ -149,14 +149,14 @@ public class SpdyStreamStatus implements Comparable<SpdyStreamStatus> {
}
/**
* Returns the code of this status.
* Returns the code of this getStatus.
*/
public int getCode() {
return code;
}
/**
* Returns the status phrase of this status.
* Returns the getStatus phrase of this getStatus.
*/
public String getStatusPhrase() {
return statusPhrase;

View File

@ -35,7 +35,7 @@ public class HttpInvalidMessageTest {
EmbeddedByteChannel ch = new EmbeddedByteChannel(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());
assertFalse(dr.isPartialFailure());
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.isPartialFailure());
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 {
EmbeddedByteChannel ch = new EmbeddedByteChannel(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());
assertFalse(dr.isPartialFailure());
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.isPartialFailure());
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());
HttpContent chunk = (HttpContent) ch.readInbound();
DecoderResult dr = chunk.decoderResult();
DecoderResult dr = chunk.getDecoderResult();
assertFalse(dr.isSuccess());
assertFalse(dr.isPartialFailure());
ensureInboundTrafficDiscarded(ch);

View File

@ -46,7 +46,7 @@ public class WebSocketServerProtocolHandlerTest {
writeUpgradeRequest(ch);
assertEquals(SWITCHING_PROTOCOLS, ((HttpResponse) ch.outboundMessageBuffer().poll()).status());
assertEquals(SWITCHING_PROTOCOLS, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus());
assertNotNull(WebSocketServerProtocolHandler.getHandshaker(handshakerCtx));
}
@ -55,10 +55,10 @@ public class WebSocketServerProtocolHandlerTest {
EmbeddedMessageChannel ch = createChannel(new MockOutboundHandler());
writeUpgradeRequest(ch);
assertEquals(SWITCHING_PROTOCOLS, ((HttpResponse) ch.outboundMessageBuffer().poll()).status());
assertEquals(SWITCHING_PROTOCOLS, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus());
ch.writeInbound(new DefaultHttpRequest(HTTP_1_1, HttpMethod.GET, "/test"));
assertEquals(FORBIDDEN, ((HttpResponse) ch.outboundMessageBuffer().poll()).status());
assertEquals(FORBIDDEN, ((HttpResponse) ch.outboundMessageBuffer().poll()).getStatus());
}
@Test
@ -75,7 +75,7 @@ public class WebSocketServerProtocolHandlerTest {
ch.writeInbound(httpRequestWithEntity);
FullHttpResponse response = getHttpResponse(ch);
assertEquals(BAD_REQUEST, response.status());
assertEquals(BAD_REQUEST, response.getStatus());
assertEquals("not a WebSocket handshake request: missing upgrade", getResponseMessage(response));
}
@ -95,7 +95,7 @@ public class WebSocketServerProtocolHandlerTest {
ch.writeInbound(httpRequest);
FullHttpResponse response = getHttpResponse(ch);
assertEquals(BAD_REQUEST, response.status());
assertEquals(BAD_REQUEST, response.getStatus());
assertEquals("not a WebSocket request: missing key", getResponseMessage(response));
}

View File

@ -104,17 +104,17 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
public void messageReceived(
ChannelHandlerContext ctx, FullHttpRequest request) throws Exception {
if (!request.decoderResult().isSuccess()) {
if (!request.getDecoderResult().isSuccess()) {
sendError(ctx, BAD_REQUEST);
return;
}
if (request.method() != GET) {
if (request.getMethod() != GET) {
sendError(ctx, METHOD_NOT_ALLOWED);
return;
}
final String uri = request.uri();
final String uri = request.getUri();
final String path = sanitizeUri(uri);
if (path == null) {
sendError(ctx, FORBIDDEN);

View File

@ -30,8 +30,8 @@ public class HttpSnoopClientHandler extends ChannelInboundMessageHandlerAdapter<
if (msg instanceof HttpResponse) {
HttpResponse response = (HttpResponse) msg;
System.out.println("STATUS: " + response.status());
System.out.println("VERSION: " + response.protocolVersion());
System.out.println("STATUS: " + response.getStatus());
System.out.println("VERSION: " + response.getProtocolVersion());
System.out.println();
if (!response.headers().isEmpty()) {

View File

@ -66,9 +66,9 @@ public class HttpSnoopServerHandler extends ChannelInboundMessageHandlerAdapter<
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");
List<Map.Entry<String, String>> headers = request.headers().entries();
if (!headers.isEmpty()) {
@ -80,7 +80,7 @@ public class HttpSnoopServerHandler extends ChannelInboundMessageHandlerAdapter<
buf.append("\r\n");
}
QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.uri());
QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.getUri());
Map<String, List<String>> params = queryStringDecoder.parameters();
if (!params.isEmpty()) {
for (Entry<String, List<String>> p: params.entrySet()) {
@ -128,7 +128,7 @@ public class HttpSnoopServerHandler extends ChannelInboundMessageHandlerAdapter<
}
private static void appendDecoderResult(StringBuilder buf, HttpObject o) {
DecoderResult result = o.decoderResult();
DecoderResult result = o.getDecoderResult();
if (result.isSuccess()) {
return;
}
@ -147,7 +147,7 @@ public class HttpSnoopServerHandler extends ChannelInboundMessageHandlerAdapter<
boolean keepAlive = isKeepAlive(request);
// Build the response object.
FullHttpResponse response = new DefaultFullHttpResponse(
HTTP_1_1, currentObj.decoderResult().isSuccess()? OK : BAD_REQUEST,
HTTP_1_1, currentObj.getDecoderResult().isSuccess()? OK : BAD_REQUEST,
Unpooled.copiedBuffer(buf.toString(), CharsetUtil.UTF_8));
response.headers().set(CONTENT_TYPE, "text/plain; charset=UTF-8");

View File

@ -229,7 +229,7 @@ public class HttpUploadClient {
// should not be since args are not null
e.printStackTrace();
} catch (ErrorDataEncoderException e) {
// test if method is a POST method
// test if getMethod is a POST getMethod
e.printStackTrace();
}
@ -314,7 +314,7 @@ public class HttpUploadClient {
// should not be since no null args
e.printStackTrace();
} catch (ErrorDataEncoderException e) {
// test if method is a POST method
// test if getMethod is a POST getMethod
e.printStackTrace();
}

View File

@ -39,8 +39,8 @@ public class HttpUploadClientHandler extends ChannelInboundMessageHandlerAdapter
if (msg instanceof HttpResponse) {
HttpResponse response = (HttpResponse) msg;
logger.info("STATUS: " + response.status());
logger.info("VERSION: " + response.protocolVersion());
logger.info("STATUS: " + response.getStatus());
logger.info("VERSION: " + response.getProtocolVersion());
if (!response.headers().isEmpty()) {
for (String name : response.headers().names()) {
@ -50,7 +50,7 @@ public class HttpUploadClientHandler extends ChannelInboundMessageHandlerAdapter
}
}
if (response.status().code() == 200 && HttpHeaders.isTransferEncodingChunked(response)) {
if (response.getStatus().code() == 200 && HttpHeaders.isTransferEncodingChunked(response)) {
readingChunks = true;
logger.info("CHUNKED CONTENT {");
} else {

View File

@ -103,7 +103,7 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
}
HttpRequest request = this.request = (HttpRequest) msg;
URI uri = new URI(request.uri());
URI uri = new URI(request.getUri());
if (!uri.getPath().startsWith("/form")) {
// Write Menu
writeMenu(ctx);
@ -113,19 +113,19 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
responseContent.append("WELCOME TO THE WILD WILD WEB SERVER\r\n");
responseContent.append("===================================\r\n");
responseContent.append("VERSION: " + request.protocolVersion().text() + "\r\n");
responseContent.append("VERSION: " + request.getProtocolVersion().text() + "\r\n");
responseContent.append("REQUEST_URI: " + request.uri() + "\r\n\r\n");
responseContent.append("REQUEST_URI: " + request.getUri() + "\r\n\r\n");
responseContent.append("\r\n\r\n");
// new method
// new getMethod
List<Entry<String, String>> headers = request.headers().entries();
for (Entry<String, String> entry : headers) {
responseContent.append("HEADER: " + entry.getKey() + '=' + entry.getValue() + "\r\n");
}
responseContent.append("\r\n\r\n");
// new method
// new getMethod
Set<Cookie> cookies;
String value = request.headers().get(COOKIE);
if (value == null) {
@ -138,7 +138,7 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
}
responseContent.append("\r\n\r\n");
QueryStringDecoder decoderQuery = new QueryStringDecoder(request.uri());
QueryStringDecoder decoderQuery = new QueryStringDecoder(request.getUri());
Map<String, List<String>> uriAttributes = decoderQuery.parameters();
for (Entry<String, List<String>> attr: uriAttributes.entrySet()) {
for (String attrVal: attr.getValue()) {
@ -301,7 +301,7 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
// Decide whether to close the connection or not.
boolean close = HttpHeaders.Values.CLOSE.equalsIgnoreCase(request.headers().get(CONNECTION))
|| request.protocolVersion().equals(HttpVersion.HTTP_1_0)
|| request.getProtocolVersion().equals(HttpVersion.HTTP_1_0)
&& !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request.headers().get(CONNECTION));
// Build the response object.

View File

@ -61,13 +61,13 @@ public class AutobahnServerHandler extends ChannelInboundMessageHandlerAdapter<O
private void handleHttpRequest(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception {
// Handle a bad request.
if (!req.decoderResult().isSuccess()) {
if (!req.getDecoderResult().isSuccess()) {
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, BAD_REQUEST));
return;
}
// Allow only GET methods.
if (req.method() != GET) {
if (req.getMethod() != GET) {
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN));
return;
}
@ -114,15 +114,15 @@ public class AutobahnServerHandler extends ChannelInboundMessageHandlerAdapter<O
private static void sendHttpResponse(
ChannelHandlerContext ctx, FullHttpRequest req, FullHttpResponse res) {
// Generate an error page if response status code is not OK (200).
if (res.status().code() != 200) {
res.data().writeBytes(Unpooled.copiedBuffer(res.status().toString(), CharsetUtil.UTF_8));
// Generate an error page if response getStatus code is not OK (200).
if (res.getStatus().code() != 200) {
res.data().writeBytes(Unpooled.copiedBuffer(res.getStatus().toString(), CharsetUtil.UTF_8));
setContentLength(res, res.data().readableBytes());
}
// Send the response and close the connection if necessary.
ChannelFuture f = ctx.channel().write(res);
if (!isKeepAlive(req) || res.status().code() != 200) {
if (!isKeepAlive(req) || res.getStatus().code() != 200) {
f.addListener(ChannelFutureListener.CLOSE);
}
}

View File

@ -90,7 +90,7 @@ public class WebSocketClientHandler extends ChannelInboundMessageHandlerAdapter<
if (msg instanceof FullHttpResponse) {
FullHttpResponse response = (FullHttpResponse) msg;
throw new Exception("Unexpected FullHttpResponse (status=" + response.status() + ", content="
throw new Exception("Unexpected FullHttpResponse (getStatus=" + response.getStatus() + ", content="
+ response.data().toString(CharsetUtil.UTF_8) + ')');
}

View File

@ -45,7 +45,7 @@ import java.net.InetSocketAddress;
* </pre>
*
* The html page is very simple were you simply enter some text and the server
* will echo the same text back, but in uppercase. You, also see status messages
* will echo the same text back, but in uppercase. You, also see getStatus messages
* in the "Response From Server" area when client has connected, disconnected
* etc.
*

View File

@ -62,19 +62,19 @@ public class WebSocketServerHandler extends ChannelInboundMessageHandlerAdapter<
private void handleHttpRequest(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception {
// Handle a bad request.
if (!req.decoderResult().isSuccess()) {
if (!req.getDecoderResult().isSuccess()) {
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, BAD_REQUEST));
return;
}
// 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);
@ -84,7 +84,7 @@ public class WebSocketServerHandler extends ChannelInboundMessageHandlerAdapter<
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;
@ -127,15 +127,15 @@ public class WebSocketServerHandler extends ChannelInboundMessageHandlerAdapter<
private static void sendHttpResponse(
ChannelHandlerContext ctx, FullHttpRequest req, FullHttpResponse res) {
// Generate an error page if response status code is not OK (200).
if (res.status().code() != 200) {
res.data().writeBytes(Unpooled.copiedBuffer(res.status().toString(), CharsetUtil.UTF_8));
// Generate an error page if response getStatus code is not OK (200).
if (res.getStatus().code() != 200) {
res.data().writeBytes(Unpooled.copiedBuffer(res.getStatus().toString(), CharsetUtil.UTF_8));
setContentLength(res, res.data().readableBytes());
}
// Send the response and close the connection if necessary.
ChannelFuture f = ctx.channel().write(res);
if (!isKeepAlive(req) || res.status().code() != 200) {
if (!isKeepAlive(req) || res.getStatus().code() != 200) {
f.addListener(ChannelFutureListener.CLOSE);
}
}

View File

@ -63,19 +63,19 @@ public class WebSocketSslServerHandler extends ChannelInboundMessageHandlerAdapt
private void handleHttpRequest(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception {
// Handle a bad request.
if (!req.decoderResult().isSuccess()) {
if (!req.getDecoderResult().isSuccess()) {
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, BAD_REQUEST));
return;
}
// 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 WebSocketSslServerHandler extends ChannelInboundMessageHandlerAdapt
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;
@ -129,15 +129,15 @@ public class WebSocketSslServerHandler extends ChannelInboundMessageHandlerAdapt
private static void sendHttpResponse(
ChannelHandlerContext ctx, FullHttpRequest req, FullHttpResponse res) {
// Generate an error page if response status code is not OK (200).
if (res.status().code() != 200) {
res.data().writeBytes(Unpooled.copiedBuffer(res.status().toString(), CharsetUtil.UTF_8));
// Generate an error page if response getStatus code is not OK (200).
if (res.getStatus().code() != 200) {
res.data().writeBytes(Unpooled.copiedBuffer(res.getStatus().toString(), CharsetUtil.UTF_8));
setContentLength(res, res.data().readableBytes());
}
// Send the response and close the connection if necessary.
ChannelFuture f = ctx.channel().write(res);
if (!isKeepAlive(req) || res.status().code() != 200) {
if (!isKeepAlive(req) || res.getStatus().code() != 200) {
f.addListener(ChannelFutureListener.CLOSE);
}
}

View File

@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit;
/**
* Keep reconnecting to the server while printing out the current uptime and
* connection attempt status.
* connection attempt getStatus.
*/
@Sharable
public class UptimeClientHandler extends ChannelInboundByteHandlerAdapter {