Repository: mina Updated Branches: refs/heads/2.0 86085a3da -> 591fccb71
o Added the missing Javadoc O Fixed some SonarLint warnings Project: http://git-wip-us.apache.org/repos/asf/mina/repo Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/591fccb7 Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/591fccb7 Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/591fccb7 Branch: refs/heads/2.0 Commit: 591fccb7187d6b3a583756910f645f4b9273e487 Parents: 86085a3 Author: Emmanuel Lécharny <elecha...@symas.com> Authored: Sat Dec 10 11:21:58 2016 +0100 Committer: Emmanuel Lécharny <elecha...@symas.com> Committed: Sat Dec 10 11:21:58 2016 +0100 ---------------------------------------------------------------------- .../java/org/apache/mina/http/ArrayUtil.java | 20 +- .../java/org/apache/mina/http/DateUtil.java | 41 ++-- .../java/org/apache/mina/http/DecoderState.java | 16 +- .../org/apache/mina/http/HttpClientCodec.java | 11 +- .../org/apache/mina/http/HttpClientDecoder.java | 212 +++++++++++-------- .../org/apache/mina/http/HttpClientEncoder.java | 25 ++- .../org/apache/mina/http/HttpException.java | 39 +++- .../org/apache/mina/http/HttpRequestImpl.java | 110 ++++++++-- .../org/apache/mina/http/HttpServerCodec.java | 12 +- .../org/apache/mina/http/HttpServerDecoder.java | 175 ++++++++------- .../org/apache/mina/http/HttpServerEncoder.java | 26 ++- .../mina/http/api/DefaultHttpResponse.java | 40 ++++ .../apache/mina/http/api/HttpContentChunk.java | 9 +- .../apache/mina/http/api/HttpEndOfContent.java | 9 +- .../org/apache/mina/http/api/HttpMessage.java | 2 +- .../org/apache/mina/http/api/HttpMethod.java | 29 ++- .../org/apache/mina/http/api/HttpRequest.java | 8 +- .../org/apache/mina/http/api/HttpResponse.java | 3 +- .../org/apache/mina/http/api/HttpStatus.java | 2 + .../java/org/apache/mina/http/api/HttpVerb.java | 30 ++- .../org/apache/mina/http/api/HttpVersion.java | 2 +- 21 files changed, 568 insertions(+), 253 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/ArrayUtil.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/ArrayUtil.java b/mina-http/src/main/java/org/apache/mina/http/ArrayUtil.java index 19d88e3..1b262c5 100644 --- a/mina-http/src/main/java/org/apache/mina/http/ArrayUtil.java +++ b/mina-http/src/main/java/org/apache/mina/http/ArrayUtil.java @@ -19,18 +19,32 @@ */ package org.apache.mina.http; +/** + * An utility class for Array manipulations. + * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> + */ public class ArrayUtil { + private ArrayUtil() { + } + /** + * Process an array of String and get rid of every Strings after an empty on. + * + * @param array The String[] array to process + * @param regex unused + * @return The resulting String[] which only contains non-empty Strings up to the first emtpy one + */ public static String[] dropFromEndWhile(String[] array, String regex) { for (int i = array.length - 1; i >= 0; i--) { - if (!array[i].trim().equals("")) { + if (!"".equals(array[i].trim())) { String[] trimmedArray = new String[i + 1]; System.arraycopy(array, 0, trimmedArray, 0, i + 1); + return trimmedArray; } } + return null; - } - } http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/DateUtil.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/DateUtil.java b/mina-http/src/main/java/org/apache/mina/http/DateUtil.java index 8822e95..87c6f22 100644 --- a/mina-http/src/main/java/org/apache/mina/http/DateUtil.java +++ b/mina-http/src/main/java/org/apache/mina/http/DateUtil.java @@ -28,15 +28,19 @@ import java.util.Locale; import java.util.TimeZone; import java.util.regex.Pattern; +/** + * An utility class for Dates manipulations + * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> + */ public class DateUtil { - - private final static Locale LOCALE = Locale.US; - private final static TimeZone GMT_ZONE; - private final static String RFC_1123_PATTERN = "EEE, dd MMM yyyy HH:mm:ss zzz"; - private final static DateFormat RFC_1123_FORMAT; + private static final Locale LOCALE = Locale.US; + private static final TimeZone GMT_ZONE; + private static final String RFC_1123_PATTERN = "EEE, dd MMM yyyy HH:mm:ss zzz"; + private static final DateFormat RFC_1123_FORMAT; /** Pattern to find digits only. */ - private final static Pattern DIGIT_PATTERN = Pattern.compile("^\\d+$"); + private static final Pattern DIGIT_PATTERN = Pattern.compile("^\\d+$"); static { RFC_1123_FORMAT = new SimpleDateFormat(DateUtil.RFC_1123_PATTERN, DateUtil.LOCALE); @@ -44,6 +48,12 @@ public class DateUtil { DateUtil.RFC_1123_FORMAT.setTimeZone(DateUtil.GMT_ZONE); } + private DateUtil() { + } + + /** + * @return The current date as a string + */ public static String getCurrentAsString() { synchronized(DateUtil.RFC_1123_FORMAT) { return DateUtil.RFC_1123_FORMAT.format(new Date()); //NOPMD @@ -59,13 +69,13 @@ public class DateUtil { * format. * @return the parsed <code>Date</code> in milliseconds. */ - private static long parseDateStringToMilliseconds(final String dateString) { + private static long parseDateStringToMilliseconds(String dateString) { try { synchronized (DateUtil.RFC_1123_FORMAT) { return DateUtil.RFC_1123_FORMAT.parse(dateString).getTime(); //NOPMD } - } catch (final ParseException e) { + } catch (ParseException e) { return 0; } } @@ -80,17 +90,12 @@ public class DateUtil { * @return the <code>long</code> value following parse, or zero where not * successful. */ - public static long parseToMilliseconds(final String dateValue) { - - long ms = 0; - + public static long parseToMilliseconds(String dateValue) { if (DateUtil.DIGIT_PATTERN.matcher(dateValue).matches()) { - ms = Long.parseLong(dateValue); + return Long.parseLong(dateValue); } else { - ms = parseDateStringToMilliseconds(dateValue); + return parseDateStringToMilliseconds(dateValue); } - - return ms; } /** @@ -100,9 +105,9 @@ public class DateUtil { * @param dateValue the <code>Date</code> represented as milliseconds. * @return a <code>String</code> representation of the date. */ - public static String parseToRFC1123(final long dateValue) { + public static String parseToRFC1123(long dateValue) { - final Calendar calendar = Calendar.getInstance(); + Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(dateValue); synchronized (DateUtil.RFC_1123_FORMAT) { http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/DecoderState.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/DecoderState.java b/mina-http/src/main/java/org/apache/mina/http/DecoderState.java index 8782ca4..8fd757b 100644 --- a/mina-http/src/main/java/org/apache/mina/http/DecoderState.java +++ b/mina-http/src/main/java/org/apache/mina/http/DecoderState.java @@ -19,8 +19,18 @@ */ package org.apache.mina.http; +/** + * The HTTP decoder states + * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> + */ public enum DecoderState { - NEW, // waiting for a new HTTP requests, the session is new of last request was completed - HEAD, // accumulating the HTTP request head (everything before the body) - BODY // receiving HTTP body slices + /** waiting for a new HTTP requests, the session is new of last request was completed */ + NEW, + + /** accumulating the HTTP request head (everything before the body) */ + HEAD, + + /** receiving HTTP body slices */ + BODY } http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/HttpClientCodec.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/HttpClientCodec.java b/mina-http/src/main/java/org/apache/mina/http/HttpClientCodec.java index c1c1f57..8f5d86f 100644 --- a/mina-http/src/main/java/org/apache/mina/http/HttpClientCodec.java +++ b/mina-http/src/main/java/org/apache/mina/http/HttpClientCodec.java @@ -25,6 +25,10 @@ import org.apache.mina.filter.codec.ProtocolCodecFilter; import org.apache.mina.filter.codec.ProtocolDecoder; import org.apache.mina.filter.codec.ProtocolEncoder; +/** + * The HTTP client codec + * @author <a href="http://mina.apache.org">Apache MINA Project</a> + */ public class HttpClientCodec extends ProtocolCodecFilter { /** Key for decoder current state */ @@ -36,15 +40,20 @@ public class HttpClientCodec extends ProtocolCodecFilter { private static ProtocolEncoder encoder = new HttpClientEncoder(); private static ProtocolDecoder decoder = new HttpClientDecoder(); + /** + * Creates a new HttpClientCodec instance + */ public HttpClientCodec() { super(encoder, decoder); } + /** + * {@inheritDoc} + */ @Override public void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws Exception { super.sessionClosed(nextFilter, session); session.removeAttribute(DECODER_STATE_ATT); session.removeAttribute(PARTIAL_HEAD_ATT); } - } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/HttpClientDecoder.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/HttpClientDecoder.java b/mina-http/src/main/java/org/apache/mina/http/HttpClientDecoder.java index c042970..069d6e2 100644 --- a/mina-http/src/main/java/org/apache/mina/http/HttpClientDecoder.java +++ b/mina-http/src/main/java/org/apache/mina/http/HttpClientDecoder.java @@ -35,6 +35,11 @@ import org.apache.mina.http.api.HttpVersion; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * An HTTP decoder + * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> + */ public class HttpClientDecoder implements ProtocolDecoder { private static final Logger LOG = LoggerFactory.getLogger(HttpClientCodec.class); @@ -77,111 +82,129 @@ public class HttpClientDecoder implements ProtocolDecoder { /** Regex to split cookie header following RFC6265 Section 5.4 */ public static final Pattern COOKIE_SEPARATOR_PATTERN = Pattern.compile(";"); - public void decode(final IoSession session, final IoBuffer msg, final ProtocolDecoderOutput out) { + /** + * {@inheritDoc} + */ + @Override + public void decode(IoSession session, IoBuffer msg, ProtocolDecoderOutput out) { DecoderState state = (DecoderState)session.getAttribute(DECODER_STATE_ATT); + if (null == state) { session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW); state = (DecoderState)session.getAttribute(DECODER_STATE_ATT); } + switch (state) { - case HEAD: - LOG.debug("decoding HEAD"); - // grab the stored a partial HEAD request - final ByteBuffer oldBuffer = (ByteBuffer)session.getAttribute(PARTIAL_HEAD_ATT); - // concat the old buffer and the new incoming one - IoBuffer.allocate(oldBuffer.remaining() + msg.remaining()).put(oldBuffer).put(msg).flip(); - // now let's decode like it was a new message - - case NEW: - LOG.debug("decoding NEW"); - final DefaultHttpResponse rp = parseHttpReponseHead(msg.buf()); - - if (rp == null) { - // we copy the incoming BB because it's going to be recycled by the inner IoProcessor for next reads - final ByteBuffer partial = ByteBuffer.allocate(msg.remaining()); - partial.put(msg.buf()); - partial.flip(); - // no request decoded, we accumulate - session.setAttribute(PARTIAL_HEAD_ATT, partial); - session.setAttribute(DECODER_STATE_ATT, DecoderState.HEAD); - } else { - out.write(rp); - // is it a response with some body content ? - LOG.debug("response with content"); - session.setAttribute(DECODER_STATE_ATT, DecoderState.BODY); - - final String contentLen = rp.getHeader("content-length"); - - if (contentLen != null) { - LOG.debug("found content len : {}", contentLen); - session.setAttribute(BODY_REMAINING_BYTES, Integer.valueOf(contentLen)); - } else if ("chunked".equalsIgnoreCase(rp.getHeader("transfer-encoding"))) { - LOG.debug("no content len but chunked"); - session.setAttribute(BODY_CHUNKED, Boolean.TRUE); - } else if ("close".equalsIgnoreCase(rp.getHeader("connection"))) { - session.closeNow(); + case HEAD: + LOG.debug("decoding HEAD"); + // grab the stored a partial HEAD request + ByteBuffer oldBuffer = (ByteBuffer)session.getAttribute(PARTIAL_HEAD_ATT); + // concat the old buffer and the new incoming one + IoBuffer.allocate(oldBuffer.remaining() + msg.remaining()).put(oldBuffer).put(msg).flip(); + // now let's decode like it was a new message + + case NEW: + LOG.debug("decoding NEW"); + DefaultHttpResponse rp = parseHttpReponseHead(msg.buf()); + + if (rp == null) { + // we copy the incoming BB because it's going to be recycled by the inner IoProcessor for next reads + ByteBuffer partial = ByteBuffer.allocate(msg.remaining()); + partial.put(msg.buf()); + partial.flip(); + // no request decoded, we accumulate + session.setAttribute(PARTIAL_HEAD_ATT, partial); + session.setAttribute(DECODER_STATE_ATT, DecoderState.HEAD); } else { - throw new HttpException(HttpStatus.CLIENT_ERROR_LENGTH_REQUIRED, "no content length !"); + out.write(rp); + // is it a response with some body content ? + LOG.debug("response with content"); + session.setAttribute(DECODER_STATE_ATT, DecoderState.BODY); + + String contentLen = rp.getHeader("content-length"); + + if (contentLen != null) { + LOG.debug("found content len : {}", contentLen); + session.setAttribute(BODY_REMAINING_BYTES, Integer.valueOf(contentLen)); + } else if ("chunked".equalsIgnoreCase(rp.getHeader("transfer-encoding"))) { + LOG.debug("no content len but chunked"); + session.setAttribute(BODY_CHUNKED, Boolean.TRUE); + } else if ("close".equalsIgnoreCase(rp.getHeader("connection"))) { + session.closeNow(); + } else { + throw new HttpException(HttpStatus.CLIENT_ERROR_LENGTH_REQUIRED, "no content length !"); + } } - } - - break; - - case BODY: - LOG.debug("decoding BODY: {} bytes", msg.remaining()); - final int chunkSize = msg.remaining(); - // send the chunk of body - if (chunkSize != 0) { - final IoBuffer wb = IoBuffer.allocate(msg.remaining()); - wb.put(msg); - wb.flip(); - out.write(wb); - } - msg.position(msg.limit()); - - // do we have reach end of body ? - int remaining = 0; - - // if chunked, remaining is the msg.remaining() - if( session.getAttribute(BODY_CHUNKED) != null ) { - remaining = chunkSize; - } else { - // otherwise, manage with content-length - remaining = (Integer) session.getAttribute(BODY_REMAINING_BYTES); - remaining -= chunkSize; - } - - if (remaining <= 0 ) { - LOG.debug("end of HTTP body"); - session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW); - session.removeAttribute(BODY_REMAINING_BYTES); + + break; + + case BODY: + LOG.debug("decoding BODY: {} bytes", msg.remaining()); + int chunkSize = msg.remaining(); + + // send the chunk of body + if (chunkSize != 0) { + IoBuffer wb = IoBuffer.allocate(msg.remaining()); + wb.put(msg); + wb.flip(); + out.write(wb); + } + + msg.position(msg.limit()); + + // do we have reach end of body ? + int remaining; + + // if chunked, remaining is the msg.remaining() if( session.getAttribute(BODY_CHUNKED) != null ) { - session.removeAttribute(BODY_CHUNKED); + remaining = chunkSize; + } else { + // otherwise, manage with content-length + remaining = (Integer) session.getAttribute(BODY_REMAINING_BYTES); + remaining -= chunkSize; } - out.write(new HttpEndOfContent()); - } else { - if( session.getAttribute(BODY_CHUNKED) == null ) { - session.setAttribute(BODY_REMAINING_BYTES, Integer.valueOf(remaining)); + + if (remaining <= 0 ) { + LOG.debug("end of HTTP body"); + session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW); + session.removeAttribute(BODY_REMAINING_BYTES); + + if( session.getAttribute(BODY_CHUNKED) != null ) { + session.removeAttribute(BODY_CHUNKED); + } + + out.write(new HttpEndOfContent()); + } else { + if( session.getAttribute(BODY_CHUNKED) == null ) { + session.setAttribute(BODY_REMAINING_BYTES, Integer.valueOf(remaining)); + } } - } - - break; - - default: - throw new HttpException(HttpStatus.SERVER_ERROR_INTERNAL_SERVER_ERROR, "Unknonwn decoder state : " + state); + + break; + + default: + throw new HttpException(HttpStatus.SERVER_ERROR_INTERNAL_SERVER_ERROR, "Unknonwn decoder state : " + state); } } - public void finishDecode(final IoSession session, final ProtocolDecoderOutput out) throws Exception { + /** + * {@inheritDoc} + */ + @Override + public void finishDecode(IoSession session, ProtocolDecoderOutput out) throws Exception { } - public void dispose(final IoSession session) throws Exception { + /** + * {@inheritDoc} + */ + @Override + public void dispose(IoSession session) throws Exception { } - private DefaultHttpResponse parseHttpReponseHead(final ByteBuffer buffer) { - // Java 6 >> String raw = new String(buffer.array(), 0, buffer.limit(), Charset.forName("UTF-8")); - final String raw = new String(buffer.array(), 0, buffer.limit()); - final String[] headersAndBody = RAW_VALUE_PATTERN.split(raw, -1); + private DefaultHttpResponse parseHttpReponseHead(ByteBuffer buffer) { + String raw = new String(buffer.array(), 0, buffer.limit()); + String[] headersAndBody = RAW_VALUE_PATTERN.split(raw, -1); + if (headersAndBody.length <= 1) { // we didn't receive the full HTTP head return null; @@ -190,24 +213,27 @@ public class HttpClientDecoder implements ProtocolDecoder { String[] headerFields = HEADERS_BODY_PATTERN.split(headersAndBody[0]); headerFields = ArrayUtil.dropFromEndWhile(headerFields, ""); - final String requestLine = headerFields[0]; - final Map<String, String> generalHeaders = new HashMap<String, String>(); + String requestLine = headerFields[0]; + Map<String, String> generalHeaders = new HashMap<>(); for (int i = 1; i < headerFields.length; i++) { - final String[] header = HEADER_VALUE_PATTERN.split(headerFields[i]); + String[] header = HEADER_VALUE_PATTERN.split(headerFields[i]); generalHeaders.put(header[0].toLowerCase(), header[1]); } - final String[] elements = RESPONSE_LINE_PATTERN.split(requestLine); + String[] elements = RESPONSE_LINE_PATTERN.split(requestLine); HttpStatus status = null; - final int statusCode = Integer.valueOf(elements[1]); + int statusCode = Integer.parseInt(elements[1]); + for (int i = 0; i < HttpStatus.values().length; i++) { status = HttpStatus.values()[i]; if (statusCode == status.code()) { + break; } } - final HttpVersion version = HttpVersion.fromString(elements[0]); + + HttpVersion version = HttpVersion.fromString(elements[0]); // we put the buffer position where we found the beginning of the HTTP body buffer.position(headersAndBody[0].length() + 4); http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/HttpClientEncoder.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/HttpClientEncoder.java b/mina-http/src/main/java/org/apache/mina/http/HttpClientEncoder.java index 26f7994..40b1981 100644 --- a/mina-http/src/main/java/org/apache/mina/http/HttpClientEncoder.java +++ b/mina-http/src/main/java/org/apache/mina/http/HttpClientEncoder.java @@ -33,23 +33,33 @@ import org.apache.mina.http.api.HttpRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * An encoder for the HTTP client + * @author <a href="http://mina.apache.org">Apache MINA Project</a> + */ public class HttpClientEncoder implements ProtocolEncoder { private static final Logger LOG = LoggerFactory.getLogger(HttpClientCodec.class); private static final CharsetEncoder ENCODER = Charset.forName("UTF-8").newEncoder(); - public void encode(IoSession session, Object message, ProtocolEncoderOutput out) - throws Exception { + /** + * {@inheritDoc} + */ + @Override + public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception { LOG.debug("encode {}", message.getClass().getCanonicalName()); + if (message instanceof HttpRequest) { LOG.debug("HttpRequest"); HttpRequest msg = (HttpRequest)message; StringBuilder sb = new StringBuilder(msg.getMethod().toString()); sb.append(" "); sb.append(msg.getRequestPath()); + if (!"".equals(msg.getQueryString())) { sb.append("?"); sb.append(msg.getQueryString()); } + sb.append(" "); sb.append(msg.getProtocolVersion()); sb.append("\r\n"); @@ -60,10 +70,8 @@ public class HttpClientEncoder implements ProtocolEncoder { sb.append(header.getValue()); sb.append("\r\n"); } + sb.append("\r\n"); - // Java 6 >> byte[] bytes = sb.toString().getBytes(Charset.forName("UTF-8")); - // byte[] bytes = sb.toString().getBytes(); - // out.write(ByteBuffer.wrap(bytes)); IoBuffer buf = IoBuffer.allocate(sb.length()).setAutoExpand(true); buf.putString(sb.toString(), ENCODER); buf.flip(); @@ -76,12 +84,13 @@ public class HttpClientEncoder implements ProtocolEncoder { // end of HTTP content // keep alive ? } - } + /** + * {@inheritDoc} + */ + @Override public void dispose(IoSession arg0) throws Exception { // TODO Auto-generated method stub - } - } http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/HttpException.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/HttpException.java b/mina-http/src/main/java/org/apache/mina/http/HttpException.java index db5d78c..b89c11f 100644 --- a/mina-http/src/main/java/org/apache/mina/http/HttpException.java +++ b/mina-http/src/main/java/org/apache/mina/http/HttpException.java @@ -21,31 +21,58 @@ package org.apache.mina.http; import org.apache.mina.http.api.HttpStatus; +/** + * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> + */ @SuppressWarnings("serial") public class HttpException extends RuntimeException { - private final int statusCode; - public HttpException(final int statusCode) { + /** + * Creates a new HttpException instance + * + * @param statusCode The associated status code + */ + public HttpException(int statusCode) { this(statusCode, ""); } - public HttpException(final HttpStatus statusCode) { + /** + * Creates a new HttpException instance + * + * @param statusCode The associated status code + */ + public HttpException(HttpStatus statusCode) { this(statusCode, ""); } - public HttpException(final int statusCode, final String message) { + /** + * Creates a new HttpException instance + * + * @param statusCode The associated status code + * @param message The error message + */ + public HttpException(int statusCode, String message) { super(message); this.statusCode = statusCode; } - public HttpException(final HttpStatus statusCode, final String message) { + /** + * Creates a new HttpException instance + * + * @param statusCode The associated status code + * @param message The error message + */ + public HttpException(HttpStatus statusCode, String message) { super(message); this.statusCode = statusCode.code(); } + /** + * @return The statusCode + */ public int getStatusCode() { return statusCode; } - } http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/HttpRequestImpl.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/HttpRequestImpl.java b/mina-http/src/main/java/org/apache/mina/http/HttpRequestImpl.java index bfba3e7..2585a36 100644 --- a/mina-http/src/main/java/org/apache/mina/http/HttpRequestImpl.java +++ b/mina-http/src/main/java/org/apache/mina/http/HttpRequestImpl.java @@ -30,8 +30,13 @@ import org.apache.mina.http.api.HttpMethod; import org.apache.mina.http.api.HttpRequest; import org.apache.mina.http.api.HttpVersion; +/** + * A HTTP Request implementation + * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> + */ public class HttpRequestImpl implements HttpRequest { - + private final HttpVersion version; private final HttpMethod method; @@ -42,6 +47,15 @@ public class HttpRequestImpl implements HttpRequest { private final Map<String, String> headers; + /** + * Creates a new HttpRequestImpl instance + * + * @param version The HTTP version + * @param method The HTTP method + * @param requestedPath The request path + * @param queryString The query string + * @param headers The headers + */ public HttpRequestImpl(HttpVersion version, HttpMethod method, String requestedPath, String queryString, Map<String, String> headers) { this.version = version; this.method = method; @@ -50,78 +64,130 @@ public class HttpRequestImpl implements HttpRequest { this.headers = headers; } + /** + * {@inheritDoc} + */ + @Override public HttpVersion getProtocolVersion() { return version; } + /** + * {@inheritDoc} + */ + @Override public String getContentType() { return headers.get("content-type"); } + /** + * {@inheritDoc} + */ + @Override public boolean isKeepAlive() { return false; } + /** + * {@inheritDoc} + */ + @Override public String getHeader(String name) { return headers.get(name); } + /** + * {@inheritDoc} + */ + @Override public boolean containsHeader(String name) { return headers.containsKey(name); } + /** + * {@inheritDoc} + */ + @Override public Map<String, String> getHeaders() { return headers; } + /** + * {@inheritDoc} + */ + @Override public boolean containsParameter(String name) { - Matcher m = parameterPattern(name); - return m.find(); + Matcher m = parameterPattern(name); + return m.find(); } + /** + * {@inheritDoc} + */ + @Override public String getParameter(String name) { - Matcher m = parameterPattern(name); - if (m.find()) { - return m.group(1); - } else { - return null; - } + Matcher m = parameterPattern(name); + if (m.find()) { + return m.group(1); + } else { + return null; + } } protected Matcher parameterPattern(String name) { - return Pattern.compile("[&]"+name+"=([^&]*)").matcher("&"+queryString); + return Pattern.compile("[&]"+name+"=([^&]*)").matcher("&"+queryString); } + /** + * {@inheritDoc} + */ + @Override public Map<String, List<String>> getParameters() { - Map<String, List<String>> parameters = new HashMap<String, List<String>>(); + Map<String, List<String>> parameters = new HashMap<>(); String[] params = queryString.split("&"); if (params.length == 1) { - return parameters; + return parameters; } for (int i = 0; i < params.length; i++) { - String[] param = params[i].split("="); - String name = param[0]; - String value = param.length == 2 ? param[1] : ""; - if (!parameters.containsKey(name)) { - parameters.put(name, new ArrayList<String>()); - } - parameters.get(name).add(value); - } + String[] param = params[i].split("="); + String name = param[0]; + String value = param.length == 2 ? param[1] : ""; + if (!parameters.containsKey(name)) { + parameters.put(name, new ArrayList<String>()); + } + parameters.get(name).add(value); + } return parameters; } + /** + * {@inheritDoc} + */ + @Override public String getQueryString() { - return queryString; + return queryString; } + /** + * {@inheritDoc} + */ + @Override public HttpMethod getMethod() { return method; } + /** + * {@inheritDoc} + */ + @Override public String getRequestPath() { - return requestedPath; + return requestedPath; } + /** + * {@inheritDoc} + */ + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("HTTP REQUEST METHOD: ").append(method).append('\n'); http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/HttpServerCodec.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/HttpServerCodec.java b/mina-http/src/main/java/org/apache/mina/http/HttpServerCodec.java index 0d7173c..45d43ac 100644 --- a/mina-http/src/main/java/org/apache/mina/http/HttpServerCodec.java +++ b/mina-http/src/main/java/org/apache/mina/http/HttpServerCodec.java @@ -25,6 +25,11 @@ import org.apache.mina.filter.codec.ProtocolCodecFilter; import org.apache.mina.filter.codec.ProtocolDecoder; import org.apache.mina.filter.codec.ProtocolEncoder; +/** + * The HTTP server codec + * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> + */ public class HttpServerCodec extends ProtocolCodecFilter { /** Key for decoder current state */ @@ -36,15 +41,20 @@ public class HttpServerCodec extends ProtocolCodecFilter { private static ProtocolEncoder encoder = new HttpServerEncoder(); private static ProtocolDecoder decoder = new HttpServerDecoder(); + /** + * Creates a new HttpServerCodec instance + */ public HttpServerCodec() { super(encoder, decoder); } + /** + * {@inheritDoc} + */ @Override public void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws Exception { super.sessionClosed(nextFilter, session); session.removeAttribute(DECODER_STATE_ATT); session.removeAttribute(PARTIAL_HEAD_ATT); } - } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/HttpServerDecoder.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/HttpServerDecoder.java b/mina-http/src/main/java/org/apache/mina/http/HttpServerDecoder.java index 56f2e6f..f3b3803 100644 --- a/mina-http/src/main/java/org/apache/mina/http/HttpServerDecoder.java +++ b/mina-http/src/main/java/org/apache/mina/http/HttpServerDecoder.java @@ -35,6 +35,11 @@ import org.apache.mina.http.api.HttpVersion; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * The HTTP decoder + * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> + */ public class HttpServerDecoder implements ProtocolDecoder { private static final Logger LOG = LoggerFactory.getLogger(HttpServerCodec.class); @@ -71,92 +76,108 @@ public class HttpServerDecoder implements ProtocolDecoder { /** Regex to split cookie header following RFC6265 Section 5.4 */ public static final Pattern COOKIE_SEPARATOR_PATTERN = Pattern.compile(";"); + /** + * {@inheritDoc} + */ + @Override public void decode(IoSession session, IoBuffer msg, ProtocolDecoderOutput out) { DecoderState state = (DecoderState) session.getAttribute(DECODER_STATE_ATT); + if (null == state) { session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW); state = (DecoderState) session.getAttribute(DECODER_STATE_ATT); } + switch (state) { - case HEAD: - LOG.debug("decoding HEAD"); - // grab the stored a partial HEAD request - final ByteBuffer oldBuffer = (ByteBuffer) session.getAttribute(PARTIAL_HEAD_ATT); - // concat the old buffer and the new incoming one - // now let's decode like it was a new message - msg = IoBuffer.allocate(oldBuffer.remaining() + msg.remaining()).put(oldBuffer).put(msg).flip(); - case NEW: - LOG.debug("decoding NEW"); - HttpRequestImpl rq = parseHttpRequestHead(msg.buf()); - - if (rq == null) { - // we copy the incoming BB because it's going to be recycled by the inner IoProcessor for next reads - ByteBuffer partial = ByteBuffer.allocate(msg.remaining()); - partial.put(msg.buf()); - partial.flip(); - // no request decoded, we accumulate - session.setAttribute(PARTIAL_HEAD_ATT, partial); - session.setAttribute(DECODER_STATE_ATT, DecoderState.HEAD); - break; - } else { - out.write(rq); - // is it a request with some body content ? - String contentLen = rq.getHeader("content-length"); - - if (contentLen != null) { - LOG.debug("found content len : {}", contentLen); - session.setAttribute(BODY_REMAINING_BYTES, Integer.valueOf(contentLen)); - session.setAttribute(DECODER_STATE_ATT, DecoderState.BODY); - // fallthrough, process body immediately + case HEAD: + LOG.debug("decoding HEAD"); + // grab the stored a partial HEAD request + ByteBuffer oldBuffer = (ByteBuffer) session.getAttribute(PARTIAL_HEAD_ATT); + // concat the old buffer and the new incoming one + // now let's decode like it was a new message + msg = IoBuffer.allocate(oldBuffer.remaining() + msg.remaining()).put(oldBuffer).put(msg).flip(); + + case NEW: + LOG.debug("decoding NEW"); + HttpRequestImpl rq = parseHttpRequestHead(msg.buf()); + + if (rq == null) { + // we copy the incoming BB because it's going to be recycled by the inner IoProcessor for next reads + ByteBuffer partial = ByteBuffer.allocate(msg.remaining()); + partial.put(msg.buf()); + partial.flip(); + // no request decoded, we accumulate + session.setAttribute(PARTIAL_HEAD_ATT, partial); + session.setAttribute(DECODER_STATE_ATT, DecoderState.HEAD); + break; } else { - LOG.debug("request without content"); + out.write(rq); + // is it a request with some body content ? + String contentLen = rq.getHeader("content-length"); + + if (contentLen != null) { + LOG.debug("found content len : {}", contentLen); + session.setAttribute(BODY_REMAINING_BYTES, Integer.valueOf(contentLen)); + session.setAttribute(DECODER_STATE_ATT, DecoderState.BODY); + // fallthrough, process body immediately + } else { + LOG.debug("request without content"); + session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW); + out.write(new HttpEndOfContent()); + break; + } + } + + case BODY: + LOG.debug("decoding BODY: {} bytes", msg.remaining()); + int chunkSize = msg.remaining(); + + // send the chunk of body + if (chunkSize != 0) { + IoBuffer wb = IoBuffer.allocate(msg.remaining()); + wb.put(msg); + wb.flip(); + out.write(wb); + } + + msg.position(msg.limit()); + // do we have reach end of body ? + int remaining = (Integer) session.getAttribute(BODY_REMAINING_BYTES); + remaining -= chunkSize; + + if (remaining <= 0) { + LOG.debug("end of HTTP body"); session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW); + session.removeAttribute(BODY_REMAINING_BYTES); out.write(new HttpEndOfContent()); - break; + } else { + session.setAttribute(BODY_REMAINING_BYTES, Integer.valueOf(remaining)); } - } - - case BODY: - LOG.debug("decoding BODY: {} bytes", msg.remaining()); - final int chunkSize = msg.remaining(); - // send the chunk of body - if (chunkSize != 0) { - final IoBuffer wb = IoBuffer.allocate(msg.remaining()); - wb.put(msg); - wb.flip(); - out.write(wb); - } - msg.position(msg.limit()); - // do we have reach end of body ? - int remaining = (Integer) session.getAttribute(BODY_REMAINING_BYTES); - remaining -= chunkSize; - - if (remaining <= 0) { - LOG.debug("end of HTTP body"); - session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW); - session.removeAttribute(BODY_REMAINING_BYTES); - out.write(new HttpEndOfContent()); - } else { - session.setAttribute(BODY_REMAINING_BYTES, Integer.valueOf(remaining)); - } - - break; - - default: - throw new HttpException(HttpStatus.CLIENT_ERROR_BAD_REQUEST, "Unknonwn decoder state : " + state); + + break; + + default: + throw new HttpException(HttpStatus.CLIENT_ERROR_BAD_REQUEST, "Unknonwn decoder state : " + state); } } - public void finishDecode(final IoSession session, final ProtocolDecoderOutput out) throws Exception { + /** + * {@inheritDoc} + */ + @Override + public void finishDecode(IoSession session, ProtocolDecoderOutput out) throws Exception { } - public void dispose(final IoSession session) throws Exception { + /** + * {@inheritDoc} + */ + @Override + public void dispose(IoSession session) throws Exception { } - private HttpRequestImpl parseHttpRequestHead(final ByteBuffer buffer) { - // Java 6 >> String raw = new String(buffer.array(), 0, buffer.limit(), Charset.forName("UTF-8")); - final String raw = new String(buffer.array(), 0, buffer.limit()); - final String[] headersAndBody = RAW_VALUE_PATTERN.split(raw, -1); + private HttpRequestImpl parseHttpRequestHead(ByteBuffer buffer) { + String raw = new String(buffer.array(), 0, buffer.limit()); + String[] headersAndBody = RAW_VALUE_PATTERN.split(raw, -1); if (headersAndBody.length <= 1) { // we didn't receive the full HTTP head @@ -166,20 +187,20 @@ public class HttpServerDecoder implements ProtocolDecoder { String[] headerFields = HEADERS_BODY_PATTERN.split(headersAndBody[0]); headerFields = ArrayUtil.dropFromEndWhile(headerFields, ""); - final String requestLine = headerFields[0]; - final Map<String, String> generalHeaders = new HashMap<String, String>(); + String requestLine = headerFields[0]; + Map<String, String> generalHeaders = new HashMap<>(); for (int i = 1; i < headerFields.length; i++) { - final String[] header = HEADER_VALUE_PATTERN.split(headerFields[i]); + String[] header = HEADER_VALUE_PATTERN.split(headerFields[i]); generalHeaders.put(header[0].toLowerCase(), header[1].trim()); } - final String[] elements = REQUEST_LINE_PATTERN.split(requestLine); - final HttpMethod method = HttpMethod.valueOf(elements[0]); - final HttpVersion version = HttpVersion.fromString(elements[2]); - final String[] pathFrags = QUERY_STRING_PATTERN.split(elements[1]); - final String requestedPath = pathFrags[0]; - final String queryString = pathFrags.length == 2 ? pathFrags[1] : ""; + String[] elements = REQUEST_LINE_PATTERN.split(requestLine); + HttpMethod method = HttpMethod.valueOf(elements[0]); + HttpVersion version = HttpVersion.fromString(elements[2]); + String[] pathFrags = QUERY_STRING_PATTERN.split(elements[1]); + String requestedPath = pathFrags[0]; + String queryString = pathFrags.length == 2 ? pathFrags[1] : ""; // we put the buffer position where we found the beginning of the HTTP body buffer.position(headersAndBody[0].length() + 4); http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/HttpServerEncoder.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/HttpServerEncoder.java b/mina-http/src/main/java/org/apache/mina/http/HttpServerEncoder.java index 0001bce..186fea0 100644 --- a/mina-http/src/main/java/org/apache/mina/http/HttpServerEncoder.java +++ b/mina-http/src/main/java/org/apache/mina/http/HttpServerEncoder.java @@ -33,14 +33,24 @@ import org.apache.mina.http.api.HttpResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * An encoder for the HTTP server + * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> + */ public class HttpServerEncoder implements ProtocolEncoder { private static final Logger LOG = LoggerFactory.getLogger(HttpServerCodec.class); private static final CharsetEncoder ENCODER = Charset.forName("UTF-8").newEncoder(); + /** + * {@inheritDoc} + */ + @Override public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception { - LOG.debug("encode {}", message.getClass().getCanonicalName()); + LOG.debug("encode {}", message.getClass().getCanonicalName()); + if (message instanceof HttpResponse) { - LOG.debug("HttpResponse"); + LOG.debug("HttpResponse"); HttpResponse msg = (HttpResponse) message; StringBuilder sb = new StringBuilder(msg.getStatus().line()); @@ -50,22 +60,26 @@ public class HttpServerEncoder implements ProtocolEncoder { sb.append(header.getValue()); sb.append("\r\n"); } + sb.append("\r\n"); IoBuffer buf = IoBuffer.allocate(sb.length()).setAutoExpand(true); buf.putString(sb.toString(), ENCODER); buf.flip(); out.write(buf); } else if (message instanceof ByteBuffer) { - LOG.debug("Body {}", message); - out.write(message); + LOG.debug("Body {}", message); + out.write(message); } else if (message instanceof HttpEndOfContent) { - LOG.debug("End of Content"); + LOG.debug("End of Content"); // end of HTTP content // keep alive ? } - } + /** + * {@inheritDoc} + */ + @Override public void dispose(IoSession session) throws Exception { // TODO Auto-generated method stub } http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/api/DefaultHttpResponse.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/api/DefaultHttpResponse.java b/mina-http/src/main/java/org/apache/mina/http/api/DefaultHttpResponse.java index 9b546ef..bfef973 100644 --- a/mina-http/src/main/java/org/apache/mina/http/api/DefaultHttpResponse.java +++ b/mina-http/src/main/java/org/apache/mina/http/api/DefaultHttpResponse.java @@ -21,6 +21,11 @@ package org.apache.mina.http.api; import java.util.Map; +/** + * The default implementation for the HTTP response element. + * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> + */ public class DefaultHttpResponse implements HttpResponse { private final HttpVersion version; @@ -29,37 +34,72 @@ public class DefaultHttpResponse implements HttpResponse { private final Map<String, String> headers; + /** + * Creates a new DefaultHttpResponse instance + * + * @param version The HTTP version + * @param status The HTTP status + * @param headers The HTTP headers + */ public DefaultHttpResponse(HttpVersion version, HttpStatus status, Map<String, String> headers) { this.version = version; this.status = status; this.headers = headers; } + /** + * {@inheritDoc} + */ + @Override public HttpVersion getProtocolVersion() { return version; } + /** + * {@inheritDoc} + */ + @Override public String getContentType() { return headers.get("content-type"); } + /** + * {@inheritDoc} + */ + @Override public boolean isKeepAlive() { // TODO check header and version for keep alive return false; } + /** + * {@inheritDoc} + */ + @Override public String getHeader(String name) { return headers.get(name); } + /** + * {@inheritDoc} + */ + @Override public boolean containsHeader(String name) { return headers.containsKey(name); } + /** + * {@inheritDoc} + */ + @Override public Map<String, String> getHeaders() { return headers; } + /** + * {@inheritDoc} + */ + @Override public HttpStatus getStatus() { return status; } http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/api/HttpContentChunk.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/api/HttpContentChunk.java b/mina-http/src/main/java/org/apache/mina/http/api/HttpContentChunk.java index 06761a6..4aa9d49 100644 --- a/mina-http/src/main/java/org/apache/mina/http/api/HttpContentChunk.java +++ b/mina-http/src/main/java/org/apache/mina/http/api/HttpContentChunk.java @@ -22,7 +22,14 @@ package org.apache.mina.http.api; import java.nio.ByteBuffer; import java.util.List; +/** + * The HTTP content chunk object + * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> + */ public interface HttpContentChunk { - + /** + * @return The list of contents + */ List<ByteBuffer> getContent(); } http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/api/HttpEndOfContent.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/api/HttpEndOfContent.java b/mina-http/src/main/java/org/apache/mina/http/api/HttpEndOfContent.java index 026cc39..003fcc8 100644 --- a/mina-http/src/main/java/org/apache/mina/http/api/HttpEndOfContent.java +++ b/mina-http/src/main/java/org/apache/mina/http/api/HttpEndOfContent.java @@ -19,8 +19,15 @@ */ package org.apache.mina.http.api; +/** + * The HTTP end of content element + * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> + */ public class HttpEndOfContent { - + /** + * {@inheritDoc} + */ @Override public String toString() { return "HttpEndOfContent"; http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/api/HttpMessage.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/api/HttpMessage.java b/mina-http/src/main/java/org/apache/mina/http/api/HttpMessage.java index 5be423e..1cf963e 100644 --- a/mina-http/src/main/java/org/apache/mina/http/api/HttpMessage.java +++ b/mina-http/src/main/java/org/apache/mina/http/api/HttpMessage.java @@ -25,7 +25,7 @@ import java.util.Map; /** * An HTTP message, the ancestor of HTTP request & response. * - * @author The Apache MINA Project (d...@mina.apache.org) + * @author <a href="http://mina.apache.org">Apache MINA Project</a> */ public interface HttpMessage { http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/api/HttpMethod.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/api/HttpMethod.java b/mina-http/src/main/java/org/apache/mina/http/api/HttpMethod.java index 5c05d0b..100cd2a 100644 --- a/mina-http/src/main/java/org/apache/mina/http/api/HttpMethod.java +++ b/mina-http/src/main/java/org/apache/mina/http/api/HttpMethod.java @@ -20,11 +20,32 @@ package org.apache.mina.http.api; /** + * The HTTP method, one of GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE, CONNECT * - * @author The Apache MINA Project (d...@mina.apache.org) - * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> */ public enum HttpMethod { - - GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE, CONNECT + /** The GET method */ + GET, + + /** The HEAD method */ + HEAD, + + /** The POST method */ + POST, + + /** The PUT method */ + PUT, + + /** The DELETE method */ + DELETE, + + /** The OPTIONS method */ + OPTIONS, + + /** The TRACE method */ + TRACE, + + /** The CONNECT method */ + CONNECT } http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/api/HttpRequest.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/api/HttpRequest.java b/mina-http/src/main/java/org/apache/mina/http/api/HttpRequest.java index f895138..1e7cb4c 100644 --- a/mina-http/src/main/java/org/apache/mina/http/api/HttpRequest.java +++ b/mina-http/src/main/java/org/apache/mina/http/api/HttpRequest.java @@ -24,10 +24,9 @@ import java.util.List; import java.util.Map; /** - * An HTTP request - * - * @author jvermillar + * An HTTP request element * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> */ public interface HttpRequest extends HttpMessage { @@ -50,6 +49,9 @@ public interface HttpRequest extends HttpMessage { */ String getParameter(String name); + /** + * @return The query part + */ String getQueryString(); /** http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/api/HttpResponse.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/api/HttpResponse.java b/mina-http/src/main/java/org/apache/mina/http/api/HttpResponse.java index cea28a0..d38b08b 100644 --- a/mina-http/src/main/java/org/apache/mina/http/api/HttpResponse.java +++ b/mina-http/src/main/java/org/apache/mina/http/api/HttpResponse.java @@ -22,8 +22,7 @@ package org.apache.mina.http.api; /** * An HTTP response to an HTTP request * - * @author The Apache MINA Project (d...@mina.apache.org) - * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> */ public interface HttpResponse extends HttpMessage { /** http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/api/HttpStatus.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/api/HttpStatus.java b/mina-http/src/main/java/org/apache/mina/http/api/HttpStatus.java index 7f35df4..a8af909 100644 --- a/mina-http/src/main/java/org/apache/mina/http/api/HttpStatus.java +++ b/mina-http/src/main/java/org/apache/mina/http/api/HttpStatus.java @@ -21,6 +21,8 @@ package org.apache.mina.http.api; /** * An <code>Enumeration</code> of all known HTTP status codes. + * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> */ public enum HttpStatus { http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/api/HttpVerb.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/api/HttpVerb.java b/mina-http/src/main/java/org/apache/mina/http/api/HttpVerb.java index 0ff719c..edfe5c7 100644 --- a/mina-http/src/main/java/org/apache/mina/http/api/HttpVerb.java +++ b/mina-http/src/main/java/org/apache/mina/http/api/HttpVerb.java @@ -19,7 +19,33 @@ */ package org.apache.mina.http.api; +/** + * The HTTP verb. One of GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE and CONNECT. + * + * @author <a href="http://mina.apache.org">Apache MINA Project</a> + */ public enum HttpVerb { - - GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE, CONNECT + /** The GET verb */ + GET, + + /** The HEAD verb */ + HEAD, + + /** The POST verb */ + POST, + + /** The PUT verb */ + PUT, + + /** The DELETE verb */ + DELETE, + + /** The OPTIONS verb */ + OPTIONS, + + /** The TRACE verb */ + TRACE, + + /** The CONNECT verb */ + CONNECT } http://git-wip-us.apache.org/repos/asf/mina/blob/591fccb7/mina-http/src/main/java/org/apache/mina/http/api/HttpVersion.java ---------------------------------------------------------------------- diff --git a/mina-http/src/main/java/org/apache/mina/http/api/HttpVersion.java b/mina-http/src/main/java/org/apache/mina/http/api/HttpVersion.java index 95655bf..98fd695 100644 --- a/mina-http/src/main/java/org/apache/mina/http/api/HttpVersion.java +++ b/mina-http/src/main/java/org/apache/mina/http/api/HttpVersion.java @@ -22,7 +22,7 @@ package org.apache.mina.http.api; /** * Type safe enumeration representing HTTP protocol version * - * @author The Apache MINA Project (d...@mina.apache.org) + * @author <a href="http://mina.apache.org">Apache MINA Project</a> */ public enum HttpVersion { /**