Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 3.1.1
-
Fix Version/s: 3.1.4 (EE only)
-
Component/s: Core: Transports
-
Labels:None
-
User impact:Medium
-
Similar Issues:None
Description
When using and method=PUT endpoint contentType won't be set (while for POST work perfectly fine) :
<http:endpoint name="exampleEndpoint" exchange-pattern="request-response"
method="PUT" host="hostname.com" port="80" path="pathtowhatever"
user="johndoe" password="dummy" contentType="application/xml" encoding="UTF-8" >
</http:endpoint>
Because on ObjectToHttpClientMethodRequest.java, there are two methods to create an HttpMethod, one for post createPostMethod and one for put createPutMethod, only the post one have this piece of code :
// if a content type was specified on the endpoint, use it
String outgoingContentType = msg.getInvocationProperty(HttpConstants.HEADER_CONTENT_TYPE);
if (outgoingContentType != null)
So as createPutMethod doen't have it, the method won't be set.
There is a dirty workaround. Adding an outbound property to the message named "Content-type" with the desired value. This will workaround it as in ObjecttoHttpClientMethodRequest.java in the method setupEntityMethod theres an : String outboundMimeType = (String) msg.getProperty(HttpConstants.HEADER_CONTENT_TYPE, PropertyScope.OUTBOUND);
Anyway a proper content-type handling for PUT is recommendable.
Issue Links
- blocks
-
MULE-5610
Content-Type header not set with PUT method
-
Same issue reported by the same guy. Already fixed in 3.2.x/3.x