I came across a situation where the client was passing multiple values for Accept header,
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,,text/xml 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. Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,text/xml *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: text/html,application/xhtml,application/xml,text/xml" *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], [Accept- encoding: gzip,deflate], [Connection: keep-alive], [Accept-language: en-US,en;q=0.5], [User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0], [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<String>> series = (Series<NamedValue<String>>) headerMap.get (HeaderConstants.ATTRIBUTE_HEADERS); if((checkHeaderAndValue(series, HeaderConstants.HEADER_ACCEPT)==false)){ throw new RestletConsumerOperationException (restUtil.buildErrorResponse(Status.CLIENT_ERROR_NOT_ACCEPTABLE)); } * * private boolean checkHeaderAndValue(Series<NamedValue<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: http://camel.465427.n5.nabble.com/Camel-Restlet-2-14-0-Accept-Header-with-multiple-values-tp5762339.html Sent from the Camel - Users mailing list archive at Nabble.com.