camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sandp <>
Subject Camel-Restlet 2.14.0 Accept Header with multiple values
Date Mon, 02 Feb 2015 19:28:41 GMT
I came across a situation where the client was passing multiple values for
Accept header,


The restlet service serves  content with mime type of *text/xml * only. When
a request 
for a resource is made, a camel processor pre-processes the request, checks
for Accept 
header, If the Accept="text/xml", the resource is served, else 406 is
returned. This works 
just fine as long the client passed a single value for Accept header.

Now the scenario is where the client passed multiple values  e.g.  

*The Question is:*
*1. *org.restlet.util.Series.getValuesArray(String name, boolean ignoreCase)
does not return an 
array of all the values associated to the given parameter name. It returns a 
single String e.g  "Accept:

*2* Is there another way to check for the multi value header?

* HEADERS from Camel Message *
org.restlet.http.headers=[[Content-type: text/xml], [Host: localhost:8090],
encoding: gzip,deflate], [Connection: keep-alive], [Accept-language:
[User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101
[Accept: text/html,application/xhtml,application/xml,text/xml]]

On the server, the Accept header is processed as below:

public void process(Exchange exchange) throws Exception {
Map<String,Object> headerMap= message.getHeaders();
Series<NamedValue&lt;String>> series = (Series<NamedValue&lt;String>>)

if((checkHeaderAndValue(series, HeaderConstants.HEADER_ACCEPT)==false)){
				throw new RestletConsumerOperationException


*  *
private boolean checkHeaderAndValue(Series<NamedValue&lt;String>> series,
String key){
		String[] headerValues =series.getValuesArray(key,true);	//*This returns a 

single string with all the values in it. As per the definition, it should
return an array of 

all the values associated to the given parameter name.

		if(null!=headerValues && headerValues.length>0){
			 List<String> headerValueList = Arrays.asList(headerValues); 
			 for(String headerValue : headerValueList){
				//Some logic
                              return true;
		return false;

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message