You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Giacomo Lamonaco <gi...@tirasa.net> on 2015/04/13 15:32:23 UTC
Response headers with multiple value
Hi all,
I'm working on some REST messages on another Apache project, Syncope.
I'm having problems with some Response headers.
Currently we build the response using the following method. Consider the
case we have multiple ERROR_CODE values, for example
RequiredValuesMissing and InvalidValues:
for (SyncopeClientException sce : ex.getExceptions()) {
builder.header(RESTHeaders.ERROR_CODE,
sce.getType().getHeaderValue());
...
}
(https://github.com/apache/syncope/blob/1_2_X/core/src/main/java/org/apache/syncope/core/rest/utils/RestServiceExceptionMapper.java
- row 156)
In our client, we get the response in this way:
List<Object> exTypesInHeaders =
response.getHeaders().get(RESTHeaders.ERROR_CODE);
(https://github.com/apache/syncope/blob/1_2_X/client/src/main/java/org/apache/syncope/client/rest/RestClientExceptionMapper.java
- row 79)
At this point, if we try to access to exTypesInHeaders, we have a list
containing only one entry, with value
"RequiredValuesMissing,InvalidValues" (a string value). What I'm
expecting instead is a list containing two entries, the first one with
value "RequiredValuesMissing" and the second one with value
"InvalidValues".
Is there some problems with multi value headers?
Thanks,
--
Giacomo Lamonaco
Re: Response headers with multiple value
Posted by Giacomo Lamonaco <gi...@tirasa.net>.
Hi Sergey,
thanks for your help. I added this line in the createServiceInstance
method of RestClientFactoryBean:
RestClientFactoryBeanWebClient.getConfig(WebClient.client(serviceInstance)).getRequestContext().put("org.apache.cxf.http.header.split",
true);
and it worked!
Regards
Il 13/04/2015 18:23, Sergey Beryozkin ha scritto:
> Hi
>
> See
>
> https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/javax/ws/rs/core/Response.html#getHeaders()
>
>
> It says that on the client side it is identical to getStringHeaders(),
> where a header with multiple values is concatenated. In some cases a
> single values may have commas, CXF was splitting by default originally
> but later on it became an optional (CXF-specific) feature, can be
> enabled by setting an
>
> "org.apache.cxf.http.header.split" contextual property
>
> HTH, Sergey
>
>
>
>
>
> On 13/04/15 08:32, Giacomo Lamonaco wrote:
>> Hi all,
>>
>> I'm working on some REST messages on another Apache project, Syncope.
>> I'm having problems with some Response headers.
>> Currently we build the response using the following method. Consider the
>> case we have multiple ERROR_CODE values, for example
>> RequiredValuesMissing and InvalidValues:
>>
>> for (SyncopeClientException sce : ex.getExceptions()) {
>> builder.header(RESTHeaders.ERROR_CODE,
>> sce.getType().getHeaderValue());
>> ...
>> }
>>
>> (https://github.com/apache/syncope/blob/1_2_X/core/src/main/java/org/apache/syncope/core/rest/utils/RestServiceExceptionMapper.java
>>
>> - row 156)
>>
>> In our client, we get the response in this way:
>>
>> List<Object> exTypesInHeaders =
>> response.getHeaders().get(RESTHeaders.ERROR_CODE);
>>
>> (https://github.com/apache/syncope/blob/1_2_X/client/src/main/java/org/apache/syncope/client/rest/RestClientExceptionMapper.java
>>
>> - row 79)
>>
>> At this point, if we try to access to exTypesInHeaders, we have a list
>> containing only one entry, with value
>> "RequiredValuesMissing,InvalidValues" (a string value). What I'm
>> expecting instead is a list containing two entries, the first one with
>> value "RequiredValuesMissing" and the second one with value
>> "InvalidValues".
>>
>> Is there some problems with multi value headers?
>>
>> Thanks,
>>
>
>
--
Giacomo Lamonaco
Tirasa - Open Source Excellence
http://www.tirasa.net/
Re: Response headers with multiple value
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
See
https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/javax/ws/rs/core/Response.html#getHeaders()
It says that on the client side it is identical to getStringHeaders(),
where a header with multiple values is concatenated. In some cases a
single values may have commas, CXF was splitting by default originally
but later on it became an optional (CXF-specific) feature, can be
enabled by setting an
"org.apache.cxf.http.header.split" contextual property
HTH, Sergey
On 13/04/15 08:32, Giacomo Lamonaco wrote:
> Hi all,
>
> I'm working on some REST messages on another Apache project, Syncope.
> I'm having problems with some Response headers.
> Currently we build the response using the following method. Consider the
> case we have multiple ERROR_CODE values, for example
> RequiredValuesMissing and InvalidValues:
>
> for (SyncopeClientException sce : ex.getExceptions()) {
> builder.header(RESTHeaders.ERROR_CODE,
> sce.getType().getHeaderValue());
> ...
> }
>
> (https://github.com/apache/syncope/blob/1_2_X/core/src/main/java/org/apache/syncope/core/rest/utils/RestServiceExceptionMapper.java
> - row 156)
>
> In our client, we get the response in this way:
>
> List<Object> exTypesInHeaders =
> response.getHeaders().get(RESTHeaders.ERROR_CODE);
>
> (https://github.com/apache/syncope/blob/1_2_X/client/src/main/java/org/apache/syncope/client/rest/RestClientExceptionMapper.java
> - row 79)
>
> At this point, if we try to access to exTypesInHeaders, we have a list
> containing only one entry, with value
> "RequiredValuesMissing,InvalidValues" (a string value). What I'm
> expecting instead is a list containing two entries, the first one with
> value "RequiredValuesMissing" and the second one with value
> "InvalidValues".
>
> Is there some problems with multi value headers?
>
> Thanks,
>