Bug 1190298
| Summary: | [GSS] (6.4.z) Impossible to set the content type HTTP header in a 204 response | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [JBoss] JBoss Enterprise Application Platform 6 | Reporter: | William Antônio <wsiqueir> | ||||||
| Component: | Web | Assignee: | Enrique Gonzalez Martinez <egonzale> | ||||||
| Status: | CLOSED CURRENTRELEASE | QA Contact: | Radim Hatlapatka <rhatlapa> | ||||||
| Severity: | unspecified | Docs Contact: | |||||||
| Priority: | unspecified | ||||||||
| Version: | 6.3.3 | CC: | bbaranow, cdewolf, egonzale, jawilson, rmaucher, rsvoboda | ||||||
| Target Milestone: | CR2 | ||||||||
| Target Release: | EAP 6.4.1 | ||||||||
| Hardware: | Unspecified | ||||||||
| OS: | Unspecified | ||||||||
| Whiteboard: | |||||||||
| Fixed In Version: | Doc Type: | Bug Fix | |||||||
| Doc Text: | Story Points: | --- | |||||||
| Clone Of: | Environment: | ||||||||
| Last Closed: | 2017-01-17 09:57:04 UTC | Type: | Bug | ||||||
| Regression: | --- | Mount Type: | --- | ||||||
| Documentation: | --- | CRM: | |||||||
| Verified Versions: | Category: | --- | |||||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||||
| Embargoed: | |||||||||
| Bug Depends On: | |||||||||
| Bug Blocks: | 1188828, 1207953 | ||||||||
| Attachments: |
|
||||||||
Created attachment 998782 [details]
patch for 7.5.7 jbossweb (invalid)
Created attachment 1003159 [details]
patch jboss 7.5.x
Attached Patch 7.5.x for this BZ.
To be complete: r2599 Bartosz Baranowski <bbaranow> updated the status of jira WFLY-4535 to Closed Just to clarify: Upstream fix is not required. undertow return the right headers. qa_acking, thank you for the test Verified with EAP 6.4.1.CP.CR2 Retroactively bulk-closing issues from released EAP 6.4 cummulative patches. |
Description of problem: When we return return 204 from a WEB application deployed in JBoss EAP, it is not possible to set the HTTP Header Content-Type. It is always removed from the HTTP response Version-Release number of selected component (if applicable): How reproducible: Always. Steps to Reproduce: 1. Create some WEB resource that will returns 204. Let's say a JAX-RS resource: @GET @Path("204") @Produces(MediaType.APPLICATION_JSON) public Response return204(@Context HttpServletResponse resp) { resp.setContentType("application/json"); return Response.status(204).build(); } 2. We can also try to set the content type using a valve: public class MyCustomValve extends ValveBase { @Override public void invoke(Request req, Response rep) throws IOException, ServletException { getNext().invoke(req, rep); rep.setContentType("Application/json"); } } Actual results: There is not Content Type header in the response. Expected results: A content type header in the response with Application/JSON value. Additional info: It seems to be a bug which was fixed in Tomcat 7.0.40(http://tomcat.apache.org/tomcat-7.0-doc/changelog.html#Tomcat_7.0.40_%28markt%29), but there is no open ticket for it. Two commits fixed it: $ git show d3d8c9db6279f5439ee8393549fec29d5b88ec49 commit d3d8c9db6279f5439ee8393549fec29d5b88ec49 Author: Mark Emlyn David Thomas <markt> Date: Sat May 4 21:49:16 2013 +0000 204 responses are permitted entity headers git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk@1479189 13f79535-47bb-0310-9956-ffa450edef68 diff --git a/java/org/apache/coyote/http11/AbstractHttp11Processor.java b/java/org/apache/coyote/http11/AbstractHttp11Processor.java index 8daac7a..3ce2165 100644 --- a/java/org/apache/coyote/http11/AbstractHttp11Processor.java +++ b/java/org/apache/coyote/http11/AbstractHttp11Processor.java @@ -1378,7 +1378,8 @@ public abstract class AbstractHttp11Processor<S> extends AbstractProcessor<S> { } MimeHeaders headers = response.getMimeHeaders(); - if (!entityBody) { + // A SC_NO_CONTENT (204) response may include entity headers + if (!entityBody && statusCode != 204) { response.setContentLength(-1); } else { String contentType = response.getContentType(); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 4d1d933..4652940 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -90,6 +90,10 @@ exception does not cause remaining checks to be skipped. Based on a patch by NateC. </fix> + <fix> + Allow 204 responses (no content) to include entity headers as required + by RFC2616. (markt) + </fix> </changelog> </subsection> <subsection name="Coyote"> and $ git show edf6d758d5f411da8e6c579265d4e1e2daf77b8c commit edf6d758d5f411da8e6c579265d4e1e2daf77b8c Author: Mark Emlyn David Thomas <markt> Date: Sun May 5 07:47:28 2013 +0000 Deal properly with 204 responses Fix an irritating warning git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk@1479249 13f79535-47bb-0310-9956-ffa450edef68 diff --git a/java/org/apache/coyote/http11/AbstractHttp11Processor.java b/java/org/apache/coyote/http11/AbstractHttp11Processor.java index 3ce2165..3c5a194 100644 --- a/java/org/apache/coyote/http11/AbstractHttp11Processor.java +++ b/java/org/apache/coyote/http11/AbstractHttp11Processor.java @@ -816,7 +816,6 @@ public abstract class AbstractHttp11Processor<S> extends AbstractProcessor<S> { InputFilter savedBody = new SavedRequestInputFilter(body); savedBody.setRequest(request); - @SuppressWarnings("unchecked") AbstractInputBuffer<S> internalBuffer = (AbstractInputBuffer<S>) request.getInputBuffer(); internalBuffer.addActiveFilter(savedBody); @@ -1378,10 +1377,11 @@ public abstract class AbstractHttp11Processor<S> extends AbstractProcessor<S> { } MimeHeaders headers = response.getMimeHeaders(); - // A SC_NO_CONTENT (204) response may include entity headers - if (!entityBody && statusCode != 204) { + if (!entityBody) { response.setContentLength(-1); - } else { + } + // A SC_NO_CONTENT response may include entity headers + if (entityBody || statusCode == 204) { String contentType = response.getContentType(); if (contentType != null) { headers.setValue("Content-Type").setString(contentType);