if ( Arrays.asList( HttpMethod.POST, HttpMethod.PUT ).contains( httpMethod ) ) {
headers.setContentType( MediaType.APPLICATION_FORM_URLENCODED );
}
headers.setAccept( Arrays.asList( MediaType.APPLICATION_JSON ) );
Authentication defaultAuthentication = context.lookup( "rest.base.auth" );
if ( defaultAuthentication != null ) {
LOG.debug( "applying default request authentication {}", defaultAuthentication );
defaultAuthentication.apply( uri, headers );
}
MultiValueMap<String, Object> values = new LinkedMultiValueMap<String, Object>();
if ( dataTable != null ) {
DataTable cleanedTable = fixTableHeader( dataTable );
boolean hasTypeSpec = cleanedTable.topCells().size() > 2;
for ( Map<String, String> row : cleanedTable.asMaps( String.class, String.class ) ) {
String name = spel.getValueAsString( row.get( "name" ) );
String value = spel.getValueAsString( row.get( "value" ) );
String type = row.get( "type" );
if ( type != null ) {
type = spel.getValueAsString( type );
}
else {
type = "data";
}
// Content-type is a special case
if ( StringUtils.startsWithIgnoreCase( type, "query" ) ) {
uri.queryParam( name, value );
}
else if ( StringUtils.equalsIgnoreCase( type, "header" ) ) {
if ( StringUtils.equalsIgnoreCase( "content-type", name ) ) {
headers.setContentType( MediaType.valueOf( value ) );
}
else {
headers.add( name, value );
}
}
else if ( StringUtils.startsWithIgnoreCase( type, "auth" )
|| ( !hasTypeSpec
&& ( StringUtils.equals( name, "auth" ) || StringUtils.equals( name, "authentication" ) ) )
) {
Authentication authentication = context.lookup( value );
if ( authentication == null ) {
fail( "No authentication configured under variable " + value );
}
LOG.debug( "applying request authentication {}", authentication );
authentication.apply( uri, headers );
}
else if ( StringUtils.equalsIgnoreCase( "content-type", name ) ) {
headers.setContentType( MediaType.valueOf( value ) );
}
else if ( StringUtils.equalsIgnoreCase( type, "data" ) ) {