You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jg...@apache.org on 2007/08/18 17:41:19 UTC

svn commit: r567279 - /geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseDecoder.java

Author: jgenender
Date: Sat Aug 18 08:41:17 2007
New Revision: 567279

URL: http://svn.apache.org/viewvc?view=rev&rev=567279
Log:
Move around the response as a session attr for a response in process

Modified:
    geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseDecoder.java

Modified: geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseDecoder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseDecoder.java?view=diff&rev=567279&r1=567278&r2=567279
==============================================================================
--- geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseDecoder.java (original)
+++ geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/codec/HttpResponseDecoder.java Sat Aug 18 08:41:17 2007
@@ -27,12 +27,19 @@
 
 public class HttpResponseDecoder extends CumulativeProtocolDecoder {
 
+    private final static String CURRENT_RESPONSE = "CURRENT_RESPONSE";
+
     private HttpDecoder httpDecoder = new HttpDecoder();
-    private HttpResponseMessage response = new HttpResponseMessage();
     private boolean headersRead = false;
 
     protected boolean doDecode(IoSession ioSession, ByteBuffer in, ProtocolDecoderOutput out) throws Exception {
 
+        HttpResponseMessage response = (HttpResponseMessage) ioSession.getAttribute(CURRENT_RESPONSE);
+        if (response == null){
+            response = new HttpResponseMessage();
+            ioSession.setAttribute(CURRENT_RESPONSE, response);
+        }
+
         //Test if we need the response...
         if (response.getStatusCode() == 0) {
             //Read the status header
@@ -71,6 +78,8 @@
         }
 
         out.write(response);
+
+        ioSession.removeAttribute(CURRENT_RESPONSE);
 
         return true;
     }