Feign: Support subtypes in Content-Type

Created on 24 Mar 2017  ·  2Comments  ·  Source: OpenFeign/feign

Hi,

i can't set the Content-Type header to Content-Type=audio/wav; codec="audio/pcm"; samplerate=16000 as i get the following exception:

Caused by: java.lang.IllegalArgumentException: MIME type may not contain reserved characters
    at org.apache.http.util.Args.check(Args.java:36) ~[httpcore-4.4.5.jar:4.4.5]
    at org.apache.http.entity.ContentType.create(ContentType.java:182) ~[httpcore-4.4.5.jar:4.4.5]
    at feign.httpclient.ApacheHttpClient.getContentType(ApacheHttpClient.java:159) ~[feign-httpclient-9.3.1.jar:na]

Problem is this line in feign.httpclient.ApacheHttpClient#getContentType:

contentType = ContentType.create(entry.getValue().iterator().next(), request.charset());

The ContentType.create() method doesn't support sub-types, but ContentType.parse() does.

bug

Most helpful comment

We had a similar problem in spring-cloud-netflix. parse() was the right way to go. Pull request?

All 2 comments

We had a similar problem in spring-cloud-netflix. parse() was the right way to go. Pull request?

Seems to be fixed in #453

Was this page helpful?
0 / 5 - 0 ratings