Return-Path: X-Original-To: apmail-cxf-issues-archive@www.apache.org Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7E4C410B06 for ; Mon, 19 Aug 2013 14:38:50 +0000 (UTC) Received: (qmail 29202 invoked by uid 500); 19 Aug 2013 14:38:49 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 29182 invoked by uid 500); 19 Aug 2013 14:38:49 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 29158 invoked by uid 99); 19 Aug 2013 14:38:47 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Aug 2013 14:38:47 +0000 Date: Mon, 19 Aug 2013 14:38:47 +0000 (UTC) From: "abdelgadiri (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CXF-5201) jaxrs2: unable to intercept response to add new response headers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CXF-5201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13743857#comment-13743857 ] abdelgadiri commented on CXF-5201: ---------------------------------- for information I found that the fix for this issue and to ensure both test cases pass with expected header is to swap the order of setting the response header and writing to the output stream. So, the fix is for the writerinterceptor to have: response.setHeader("bug4986TestHeaderName", "bug4986TestHeaderValue"); originalStream.write(base64Body.getBytes("UTF-8")); instead of: originalStream.write(base64Body.getBytes("UTF-8")); response.setHeader("bug4986TestHeaderName", "bug4986TestHeaderValue"); this hints that org.apache.cxf.transport.http.AbstractHTTPDestination$WrappedOutputStream is making an incorrect assumptions when writing to the output stream > jaxrs2: unable to intercept response to add new response headers > ---------------------------------------------------------------- > > Key: CXF-5201 > URL: https://issues.apache.org/jira/browse/CXF-5201 > Project: CXF > Issue Type: Bug > Components: JAX-RS > Affects Versions: 2.7.5, 2.7.6 > Environment: windows > Reporter: abdelgadiri > Attachments: bug4986-1.0.war, bug4986.zip > > > In a WriterInterceptor, one expects to be able to modify response headers via: > //here using putSingle() but could also use on of the addXXX variants > context.getHeaders().putSingle("headerName", headerValue); > However, above is not working in 2.7.5/2.7.6 (@see JIRA-4986) > As a workaround, one should be able to inject the HttpServletResponse object via: @Context HttpServletResponse response; > then be able to add headers directly to the response object e.g., > response.setHeader("headerName", headerValue); > however, above is also not working in (2.7.5/2.7.6). This is not always reproducable as sometimes my client does see the new headers in the received response. On closer look it seems the added headers get lost when it is a @GET request as opposed to e.g., a @POST. Basically, my test case (a @GET) always fails with a missing header in the received response even though I am pretty sure the server had added the header. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira