camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jay mann (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CAMEL-9642) restlet consumer request not propagating headers
Date Wed, 24 Feb 2016 23:08:18 GMT

     [ https://issues.apache.org/jira/browse/CAMEL-9642?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Jay mann updated CAMEL-9642:
----------------------------
    Description: 
Headers are not getting propagating from restlet consumers.  The code is setting them incorrectly
inside DefaultRestletBinding.java -> populateRestletRequestFromExchange


This is the code that works (based on latest from github):

{code}
 for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
            String key = entry.getKey();
            Object value = entry.getValue();
            if (!headerFilterStrategy.applyFilterToCamelHeaders(key, value, exchange)) {
                // put the org.restlet headers in attributes
            	if (key.startsWith("org.restlet.")) {
                    if(key.equals("org.restlet.http.headers")){
                        //Check if existing headers already exist
                    	Series<Header> headers = (Series)request.getAttributes().get("org.restlet.http.headers");
    	               	if(headers != null){ //If headers exists add them to the existing ones
    	               		Series<Header> newHeaders = (Series)value;
    	               		for(Header h: newHeaders){
                                headers.set(key, value.toString());                    	
    	               		}
    	               	}
    	               	else{
                            request.getAttributes().put(key, value);
    	               	}
                    }
                    else{
                        request.getAttributes().put(key, value);
                    }
                    	
                }
                // Use forms only for PUT, POST and x-www-form-urlencoded
            	else if (form != null) {
                    // put the user stuff in the form
                    if (value instanceof Collection) {
                        for (Object v : (Collection<?>) value) {
                            form.add(key, v.toString());
                        }
                    } else {
                        form.add(key, value.toString());
                    }
                }else {
                    // For non-form put all the headers in attributes header
                	Series<Header> headers = (Series)request.getAttributes().get("org.restlet.http.headers");
	               	if(headers == null){
	               		headers = new Series<Header>(Header.class);
	               		request.getAttributes().put("org.restlet.http.headers", headers);
	               	}
                    headers.set(key, value.toString());
                }

                LOG.debug("Populate Restlet request from exchange header: {} value: {}", key,
value);
            }
        }
{code}




  was:
Headers are not getting propagating from restlet consumers.  The code is setting them incorrectly
inside DefaultRestletBinding.java -> populateRestletRequestFromExchange



This is the code that works (based on latest from github):

{code}
 for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
            String key = entry.getKey();
            Object value = entry.getValue();
            if (!headerFilterStrategy.applyFilterToCamelHeaders(key, value, exchange)) {
                // put the org.restlet headers in attributes
            	if (key.startsWith("org.restlet.")) {
                    if(key.equals("org.restlet.http.headers")){
                        //Check if existing headers already exist
                    	Series<Header> headers = (Series)request.getAttributes().get("org.restlet.http.headers");
    	               	if(headers != null){ //If headers exists add them to the existing ones
    	               		Series<Header> newHeaders = (Series)value;
    	               		for(Header h: newHeaders){
                                headers.set(key, value.toString());                    	
    	               		}
    	               	}
    	               	else{
                            request.getAttributes().put(key, value);
    	               	}
                    }
                    else{
                        request.getAttributes().put(key, value);
                    }
                    	
                }
                // Use forms only for PUT, POST and x-www-form-urlencoded
            	else if (form != null) {
                    // put the user stuff in the form
                    if (value instanceof Collection) {
                        for (Object v : (Collection<?>) value) {
                            form.add(key, v.toString());
                        }
                    } else {
                        form.add(key, value.toString());
                    }
                }else {
                    // For non-form put all the headers in attributes header
                	Series<Header> headers = (Series)request.getAttributes().get("org.restlet.http.headers");
	               	if(headers == null){
	               		headers = new Series<Header>(Header.class);
	               		request.getAttributes().put("org.restlet.http.headers", headers);
	               	}
                    headers.set(key, value.toString());
                }

                LOG.debug("Populate Restlet request from exchange header: {} value: {}", key,
value);
            }
        }
{code}





> restlet consumer request not propagating headers
> ------------------------------------------------
>
>                 Key: CAMEL-9642
>                 URL: https://issues.apache.org/jira/browse/CAMEL-9642
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-restlet
>    Affects Versions: 2.16.2
>            Reporter: Jay mann
>
> Headers are not getting propagating from restlet consumers.  The code is setting them
incorrectly inside DefaultRestletBinding.java -> populateRestletRequestFromExchange
> This is the code that works (based on latest from github):
> {code}
>  for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet())
{
>             String key = entry.getKey();
>             Object value = entry.getValue();
>             if (!headerFilterStrategy.applyFilterToCamelHeaders(key, value, exchange))
{
>                 // put the org.restlet headers in attributes
>             	if (key.startsWith("org.restlet.")) {
>                     if(key.equals("org.restlet.http.headers")){
>                         //Check if existing headers already exist
>                     	Series<Header> headers = (Series)request.getAttributes().get("org.restlet.http.headers");
>     	               	if(headers != null){ //If headers exists add them to the existing
ones
>     	               		Series<Header> newHeaders = (Series)value;
>     	               		for(Header h: newHeaders){
>                                 headers.set(key, value.toString());                 
  	
>     	               		}
>     	               	}
>     	               	else{
>                             request.getAttributes().put(key, value);
>     	               	}
>                     }
>                     else{
>                         request.getAttributes().put(key, value);
>                     }
>                     	
>                 }
>                 // Use forms only for PUT, POST and x-www-form-urlencoded
>             	else if (form != null) {
>                     // put the user stuff in the form
>                     if (value instanceof Collection) {
>                         for (Object v : (Collection<?>) value) {
>                             form.add(key, v.toString());
>                         }
>                     } else {
>                         form.add(key, value.toString());
>                     }
>                 }else {
>                     // For non-form put all the headers in attributes header
>                 	Series<Header> headers = (Series)request.getAttributes().get("org.restlet.http.headers");
> 	               	if(headers == null){
> 	               		headers = new Series<Header>(Header.class);
> 	               		request.getAttributes().put("org.restlet.http.headers", headers);
> 	               	}
>                     headers.set(key, value.toString());
>                 }
>                 LOG.debug("Populate Restlet request from exchange header: {} value: {}",
key, value);
>             }
>         }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message