You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Sergey Beryozkin (JIRA)" <ji...@apache.org> on 2017/04/03 11:01:41 UTC

[jira] [Commented] (CXF-7310) org.apache.cxf.jaxrs.client.ClientProxyImpl#getAccept does not handle Accept header with multiple media types

    [ https://issues.apache.org/jira/browse/CXF-7310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15953278#comment-15953278 ] 

Sergey Beryozkin commented on CXF-7310:
---------------------------------------

Underlying AbstractClient has the accept method accepting multiple individual String values. However I did the proposed update given that the same issue was reported against Consumes/Produces annotations (even though they support an array of media types) 

> 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)