camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steffen F. (JIRA)" <>
Subject [jira] [Created] (CAMEL-11509) Cannot set content type with parameters without specifying charset
Date Tue, 04 Jul 2017 12:05:00 GMT
Steffen F. created CAMEL-11509:

             Summary: Cannot set content type with parameters without specifying charset
                 Key: CAMEL-11509
             Project: Camel
          Issue Type: Bug
          Components: camel-http4
    Affects Versions: 2.19.1, 2.19.0
            Reporter: Steffen F.

When setting a content type that does not contain a charset parameter, for example this:

.setHeader("Content-Type", constant("application/json;odata=verbose"))

the route will fail with the following exception:

java.lang.IllegalArgumentException: MIME type may not contain reserved characters
	at org.apache.http.util.Args.check(
	at org.apache.http.entity.ContentType.create(
	at org.apache.http.entity.ContentType.create(
	at org.apache.camel.component.http4.HttpProducer.createRequestEntity(

although this is clearly a valid content type according to the RFC:

This only affects version 2.19+, because in version 4.4.6 of the httpcomponents-core library,
they changed the behavior of {{create}} to check the mime type for semicolons, which it previously
didn't. If we, however, also use a charset parameter, you will call the {{parse}} method instead:

if (contentTypeString != null) {
    if (contentTypeString.indexOf("charset") > 0) {
        contentType = ContentType.parse(contentTypeString);
    } else {
        contentType = ContentType.create(contentTypeString);

There can be all kind of different parameters, though. Instead of checking for charset, it
should rather check for the existence of a semicolon. 

This message was sent by Atlassian JIRA

View raw message