Hide Forgot
+++ This bug was initially created as a clone of Bug #1319552 +++ Description of problem: It does not matter is a request is done using application/json, the response always returns application/xml in the header. The payload content is correct. Steps to Reproduce: 1. Send a request to kie-server to fire-all-rules with application/json in the header Actual results: The response header has application/xml instead of application/json Expected results: application/json in the header
headers are controlled based on given Accept request header as it's calculated based on variant sent on the response object. So make sure you instruct what is accepted content type by the client by setting Accept header: Accept = application/json once you set the expectations server will respond with proper content type set on response. I don't think there is anything to do in the code if client follows HTTP communication best practice.
Hi Maciej, I see Accept as a header to define which kind of medias are acceptable in the response content, a way to restrict and filter the content that we can consume: "The Accept request-header field *can be used* to specify certain media types which are acceptable for the response. Accept headers can be used to indicate that the request is specifically limited to a small set of desired types" (https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) If customer set json in Accept, it should only consume json content-type ad we should send that in the payload - that is fine. if customer does not set any accept, it may be receive any content-type - but the content-type header should have the vale correct with what is delivered. We are sending in response the content-type header with a value different than that really sent in the response payload. The content sent is json, but the header says xml. Another example, if we set as Accept "application/json,application/xml" (customer client can handle xml or json) and we set X-KIE-ContentType as "JSON" the server will reply with a json content but with content-type as xml, which is incorrect. I hope this clarify the issue.
Just noticed one thing, if I set Content-Type header to application/xml, Accept header to application/json and send request in XML format, Kie server will throw marshalling error. It seems to be caused by Kie server unmarshalling request content according to format defined in Accept header.
since this has not be done on any of the branches at the moment - PR is on master I'd opt to move it out from the coming patch to make sure we don't introduce any regressions because of it Thoughts?
That is fine Maciej, Let's remove it from 6.2.z and change it to 6.3.z (Update 1) The issue is not critical and Accept works for users that needs to receive a correct content-type header in response. For 6.3 udpate 1 the expectation is to get a fix for the scenario where no Accept is sent but the content provided is not equal to the content-type header - or if two Accepts are sent, the return should be consistent with the content-type header.
fix has been merged to master so for the rollup patch it needs to be back ported once approved droolsjbpm-integration master: https://github.com/droolsjbpm/droolsjbpm-integration/commit/2d791924c265edf1bba78add9f3fbccf332d8431