You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2011/02/10 18:46:59 UTC

DO NOT REPLY [Bug 50753] New: Asynchronous responses do not contain set response headers

https://issues.apache.org/bugzilla/show_bug.cgi?id=50753

           Summary: Asynchronous responses do not contain set response
                    headers
           Product: Tomcat 7
           Version: 7.0.6
          Platform: PC
        OS/Version: Mac OS X 10.5
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: mircea.toma@icesoft.com


Using a servlet with asynchronous support enabled and the response headers set
just before AsyncContext.complete() method is called fails to send the headers
over the wire. More precisely if the headers are set on the HttpServletRequest
on a different thread than the request thread the headers are not sent. 

A simple test was devised to showcase the issue.

Setting the headers on the request thread before or after the AsyncContext is
acquired *succeeds* in sending the headers over the wire: 

    protected void doGet(HttpServletRequest request, final HttpServletResponse
r) throws ServletException, IOException { 
       final AsyncContext ctx = request.startAsync(); 
        r.setHeader("A", "xyz"); 
        r.setContentType("text/plain"); 
        r.setContentLength("------".getBytes().length); 
        r.getWriter().print("------"); 
        ctx.start(new Runnable() { 
            public void run() { 
                try { 
                    Thread.sleep(5000); 
                    ctx.complete(); 
                } catch (Exception e) { 
                    e.printStackTrace();
                } 
            } 
        }); 
    } 

Setting the headers just before the response is sent *does not succeed* in
actually sending the headers over the wire: 

    protected void doGet(HttpServletRequest request, final HttpServletResponse
r) throws ServletException, IOException { 
       final AsyncContext ctx = request.startAsync(); 
        ctx.start(new Runnable() { 
            public void run() { 
                try { 
                    Thread.sleep(5000); 
                    r.setHeader("A", "xyz"); 
                    r.setContentType("text/plain"); 
                    r.setContentLength("------".getBytes().length); 
                    r.getWriter().print("------"); 
                    ctx.complete(); 
                } catch (Exception e) { 
                    e.printStackTrace();
                } 
            } 
        }); 
    }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 50753] Asynchronous responses do not contain set response headers

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50753

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME

--- Comment #2 from Mark Thomas <ma...@apache.org> 2011-02-10 14:43:30 EST ---
This works for me with the latest Tomcat 7.0.x code and is probably (depending
on exactly which change fixed this) fixed in the recently released 7.0.8 as
well.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 50753] Asynchronous responses do not contain set response headers

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50753

--- Comment #1 from Mircea Toma <mi...@icesoft.com> 2011-02-10 12:48:05 EST ---
http://jira.icefaces.org/browse/PUSH-116 is the original issue.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 50753] Asynchronous responses do not contain set response headers

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50753

--- Comment #3 from Mircea Toma <mi...@icesoft.com> 2011-02-10 16:55:46 EST ---
Indeed, I can confirm that headers are sent properly when using Tomcat 7.0.8.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org