* Renamed HttpVersion.getProtocol() to decode()

* A little bit of code clean up
This commit is contained in:
Trustin Lee 2008-11-26 08:49:33 +00:00
parent 1ff2b7bbc9
commit 796238d929
6 changed files with 9 additions and 16 deletions

View File

@ -41,10 +41,8 @@ import org.jboss.netty.buffer.ChannelBuffer;
public class DefaultHttpMessage implements HttpMessage { public class DefaultHttpMessage implements HttpMessage {
private final static Comparator<String> caseIgnoringComparator = new CaseIgnoringComparator(); private final static Comparator<String> caseIgnoringComparator = new CaseIgnoringComparator();
Map<String, List<String>> headers = new TreeMap<String, List<String>>(caseIgnoringComparator);
private final HttpVersion version; private final HttpVersion version;
private final Map<String, List<String>> headers = new TreeMap<String, List<String>>(caseIgnoringComparator);
private ChannelBuffer content; private ChannelBuffer content;
protected DefaultHttpMessage(final HttpVersion version) { protected DefaultHttpMessage(final HttpVersion version) {

View File

@ -39,7 +39,7 @@ public class HttpRequestDecoder extends HttpMessageDecoder {
String line = readIntoCurrentLine(buffer); String line = readIntoCurrentLine(buffer);
checkpoint(ResponseState.READ_HEADER); checkpoint(ResponseState.READ_HEADER);
String[] split = splitInitial(line); String[] split = splitInitial(line);
message = new DefaultHttpRequest(HttpVersion.getProtocol(split[2]), HttpMethod.valueOf(split[0]), new URI(split[1])); message = new DefaultHttpRequest(HttpVersion.decode(split[2]), HttpMethod.valueOf(split[0]), new URI(split[1]));
} }
} }

View File

@ -36,6 +36,6 @@ public class HttpResponseDecoder extends HttpMessageDecoder {
String line = readIntoCurrentLine(buffer); String line = readIntoCurrentLine(buffer);
checkpoint(ResponseState.READ_HEADER); checkpoint(ResponseState.READ_HEADER);
String[] split = splitInitial(line); String[] split = splitInitial(line);
message = new DefaultHttpResponse(HttpVersion.getProtocol(split[0]), new HttpResponseStatus(Integer.valueOf(split[1]), split[2])); message = new DefaultHttpResponse(HttpVersion.decode(split[0]), new HttpResponseStatus(Integer.valueOf(split[1]), split[2]));
} }
} }

View File

@ -30,22 +30,20 @@ package org.jboss.netty.handler.codec.http;
*/ */
public enum HttpVersion { public enum HttpVersion {
HTTP_1_0("HTTP/1.0"), HTTP_1_0("HTTP/1.0"),
HTTP_1_1("HTTP/1.1"), HTTP_1_1("HTTP/1.1"),
UNKNOWN("UNKNOWN"),; UNKNOWN("UNKNOWN"),;
private String version; private final String version;
private HttpVersion(String value) { private HttpVersion(String version) {
version = value; this.version = version;
} }
public String value() { public String value() {
return version; return version;
} }
public static HttpVersion getProtocol(String value) { public static HttpVersion decode(String value) {
if (value == null) { if (value == null) {
return UNKNOWN; return UNKNOWN;
} }

View File

@ -34,9 +34,7 @@ import java.util.Map;
public class QueryStringDecoder { public class QueryStringDecoder {
private final String uri; private final String uri;
private String path; private String path;
private final Map<String, List<String>> params = new HashMap<String, List<String>>(); private final Map<String, List<String>> params = new HashMap<String, List<String>>();
public QueryStringDecoder(String uri) { public QueryStringDecoder(String uri) {

View File

@ -32,9 +32,8 @@ import java.util.List;
*/ */
public class QueryStringEncoder { public class QueryStringEncoder {
final String url; private final String url;
private final List<Param> params = new ArrayList<Param>();
final List<Param> params = new ArrayList<Param>();
public QueryStringEncoder(String url) { public QueryStringEncoder(String url) {
this.url = url; this.url = url;