Roman created CXF-7310:
--------------------------
Summary: org.apache.cxf.jaxrs.client.ClientProxyImpl#getAccept
does not handle Accept header with multiple media types
Key: CXF-7310
URL: https://issues.apache.org/jira/browse/CXF-7310
Project: CXF
Issue Type: Bug
Components: JAX-RS
Affects Versions: 3.1.10
Reporter: Roman
The org.apache.cxf.jaxrs.client.ClientProxyImpl#getAccept method does not
handle an accept header with multiple media types like so:
{code}
Accept: application/json, text/plan, */*
{code}
It throws an exception:
{code}
Caused by: java.lang.IllegalArgumentException: Invalid media type string:
application/json, text/plain, */*
at
org.apache.cxf.jaxrs.impl.MediaTypeHeaderProvider.internalValueOf(MediaTypeHeaderProvider.java:90)
at
org.apache.cxf.jaxrs.impl.MediaTypeHeaderProvider.valueOf(MediaTypeHeaderProvider.java:65)
at
org.apache.cxf.jaxrs.utils.JAXRSUtils.toMediaType(JAXRSUtils.java:1723)
at
org.apache.cxf.jaxrs.client.ClientProxyImpl.getAccept(ClientProxyImpl.java:396)
at
org.apache.cxf.jaxrs.client.ClientProxyImpl.setRequestHeaders(ClientProxyImpl.java:367)
{code}
I think the Accept header value needs to be split by ',' and each part passed
to JAXRSUtils.toMediaType(...) to parse each correctly in this code:
{code}
for (String s : headers) {
types.add(JAXRSUtils.toMediaType(s));
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)