You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by je...@apache.org on 2013/11/27 13:26:10 UTC

[7/8] git commit: Apply the DIRMINA-933 patch

Apply the DIRMINA-933 patch

Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/89605f0d
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/89605f0d
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/89605f0d

Branch: refs/heads/2.0
Commit: 89605f0db26813eaaaac450c1f61ef9bbccdc595
Parents: 885ec9f
Author: Emmanuel Lécharny <el...@apache.org>
Authored: Thu Apr 11 00:15:31 2013 +0200
Committer: Jeff MAURY <je...@apache.org>
Committed: Wed Nov 27 13:23:06 2013 +0100

----------------------------------------------------------------------
 .../java/org/apache/mina/http/HttpServerDecoder.java | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/89605f0d/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 e9d09b8..61c1933 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
@@ -71,7 +71,7 @@ public class HttpServerDecoder 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) {
+    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);
@@ -85,37 +85,38 @@ public class HttpServerDecoder implements ProtocolDecoder {
             // 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
-
+            msg = IoBuffer.allocate(oldBuffer.remaining() + msg.remaining()).put(oldBuffer).put(msg).flip();
         case NEW:
             LOG.debug("decoding NEW");
-            final HttpRequestImpl rq = parseHttpRequestHead(msg.buf());
+            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
-                final ByteBuffer partial = ByteBuffer.allocate(msg.remaining());
+                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 ?
-                final String contentLen = rq.getHeader("content-length");
+                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;
                 }
             }
 
-            break;
-
         case BODY:
             LOG.debug("decoding BODY: {} bytes", msg.remaining());
             final int chunkSize = msg.remaining();